Cron job is not working
6,335
Solution 1
You have to execute it using sh
;
here is my example
[email protected]
30 11 * * * sh /home/user/backup.sh
30 17 * * * sh /home/user/backup.sh
have a look here cronjob
Solution 2
Fixed this issue. It was a permission issue of calling sh files from cron.
Related videos on Youtube
Author by
Prajila V P
Updated on September 18, 2022Comments
-
Prajila V P over 1 year
I have a cron job configured at
var/spool/cron/testuser
, Am callingadindex.sh
file from there.Am getting results when am directly put the command directly in prompt(php and sh), But cron is not processing this one. I tried to log the cron using
tail -f /var/log/cron
and got:Feb 19 04:05:01 ip-118-139-177-76 CROND[18164]: (inwhosting) CMD (/home/testuser/cronlogs/adindex.sh)
Edit: Output for crontab -l
MAILTO="" */5 * * * * /home/testuser/cronlogs/adindex.sh */5 * * * * /home/testuser/cronlogs/sendemail.sh */5 * * * * /home/testuser/cronlogs/sendsms.sh
Ouput of cat /home/testuser/cronlogs/adindex.sh
#wget --user=admin--password=pswd123 http://www.exmaple.com/advertiser/cron/updateindex?cron_key=Inw1234 -O /home/testuser/cronlogs/ad/log_`date "+%Y_%m_%d_%H_%M"`.txt php /var/www/html/exmaple/cron/advt_index.php php /var/www/html/exmaple/cron/ad_index.php
Anybody please tell me what is going wrong?
-
X Tian about 10 yearsThere's a typo somewhere in your question is adindex.sh a php script or a shell script. your log shows cron is attempting to execute your command, what does your command look like why do you think it isn't running ?
-
Prajila V P about 10 yearsMy cron job is to index the solr database, and it is not indexing via cron job. I tried this via command line and works fine
-
S edwards about 10 yearswhat is the name of your script ? is it a php script or shell script ?
-
Prajila V P about 10 yearsin main cron page i am giving a shell script adindex.sh, which is for executing some php scripts
-
S edwards about 10 yearscan you edit your question to add the result of
cron -l
-
Hauke Laging about 10 yearsIs
php
incron
's$PATH
? -
Angel Todorov about 10 yearsAre you executing the shell script with a php interpreter?
-
Prajila V P about 10 yearsFixed the issue. It was "Permission denied" problem from cron
-
Kusalananda about 5 yearsSince the user has "a cron job configured at var/spool/cron/testuser", it makes me believe they manually edited that file rather than using
crontab -e
. This would explain why some jobs are not running.
-
-
phemmer about 10 yearsOr
chmod a+x /home/user/backup.sh
(assuming it has a shebang).