Script in crontab did not run
Hello,
I have some trouble running scripts via cron. I like to run two scripts via cron. My /etc/crontab looks like:
root@host>cat /etc/crontab SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin # For details see man 4 crontabs # Example of job definition: # .---------------- minute (0 - 59) # | .------------- hour (0 - 23) # | | .---------- day of month (1 - 31) # | | | .------- month (1 - 12) OR jan,feb,mar,apr ... # | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat # | | | | | # * * * * * user-name command to be executed 1 0 * * * root /root/bin/do_reposync.sh 2 1 * * * root /root/bin/update_rhel-e-stage.sh && /root/bin/update_rhel-i-stage.sh
The first script runs as expected. The second one not. When I run the second command in bash like:
root@host>/root/bin/update_rhel-e-stage.sh && /root/bin/update_rhel-i-stage.sh
It works just fine.
My first guess was to check if there is a linebreak after the second command and it is. The second guess was, that I have an issue with the '&&'. So I wrote a short wrapper-script and changed the crontab to:
root@host>cat /etc/crontab SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin # For details see man 4 crontabs # Example of job definition: # .---------------- minute (0 - 59) # | .------------- hour (0 - 23) # | | .---------- day of month (1 - 31) # | | | .------- month (1 - 12) OR jan,feb,mar,apr ... # | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat # | | | | | # * * * * * user-name command to be executed 1 0 * * * root /root/bin/do_reposync.sh 2 1 * * * root /root/bin/update_multiple_stages.sh
But again the second command was not executed via cron while running correct when executed in bash. I use vim to edit the /etc/crontab.
The log (filtered for CROND) shows the following for the timeframe:
Jun 16 09:10:01 rpm-repo CROND[28708]: (root) CMD (/usr/lib64/sa/sa1 1 1) Jun 16 09:15:01 rpm-repo CROND[28717]: (root) CMD (/root/bin/update_rhel-e-stage.sh && /root/bin/update_rhel-i-stage.sh) Jun 16 09:20:01 rpm-repo CROND[28732]: (root) CMD (/usr/lib64/sa/sa1 1 1) Jun 16 09:30:01 rpm-repo CROND[28740]: (root) CMD (/usr/lib64/sa/sa1 1 1) Jun 16 09:40:02 rpm-repo CROND[28789]: (root) CMD (/usr/lib64/sa/sa1 1 1) Jun 16 09:50:01 rpm-repo CROND[28805]: (root) CMD (/usr/lib64/sa/sa1 1 1) Jun 16 10:00:01 rpm-repo CROND[28970]: (root) CMD (/usr/lib64/sa/sa1 1 1) Jun 16 10:01:01 rpm-repo CROND[28976]: (root) CMD (run-parts /etc/cron.hourly) Jun 16 10:05:01 rpm-repo CROND[28995]: (root) CMD (/root/bin/update_multiple_stages.sh) Jun 16 10:10:01 rpm-repo CROND[29009]: (root) CMD (/usr/lib64/sa/sa1 1 1) Jun 16 10:20:01 rpm-repo CROND[29047]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Do anyone have an idea what is causing this issue or how to debug it?
Best regards,
Joerg K.
Responses