Fli
08-30-2014, 12:38 PM
My cronjobs was not executed when i added bash scripts into /etc/cron.d directory on linux server.
but i got it fixed then, so i want to share what helped.
I set rights to the files in cron.d drectory to 600 (only user root can have access to them)
# chmod 600 /etc/cron.d/myjobs
-rw------- 1 root root 326 Jul 13 06:27 dailyjobs
then inside myjobs i have:
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
*/1 * * * * root /bin/sh /root/cpudiskreport >/dev/null 2>&1
*/2 * * * * root /bin/sh /root/vmsuspender >/dev/null 2>&1
58 * * * * root /bin/sh /root/loadreport >/dev/null 2>&1
* * * * * root /root/crontest >/dev/null 2>&1
you see i have user "root" in each cron command. " >/dev/null 2>&1" is not necessary, it just make sure cronjobs dont send out any error/nonerror emails.
*/1 * * * * is minutelly cron
58 * * * * is cron run every hour in 58th minute
If you have issue with crons, try to watch crontab logfile: /var/log/cron
# tail -n30 /var/log/cron
but i got it fixed then, so i want to share what helped.
I set rights to the files in cron.d drectory to 600 (only user root can have access to them)
# chmod 600 /etc/cron.d/myjobs
-rw------- 1 root root 326 Jul 13 06:27 dailyjobs
then inside myjobs i have:
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
*/1 * * * * root /bin/sh /root/cpudiskreport >/dev/null 2>&1
*/2 * * * * root /bin/sh /root/vmsuspender >/dev/null 2>&1
58 * * * * root /bin/sh /root/loadreport >/dev/null 2>&1
* * * * * root /root/crontest >/dev/null 2>&1
you see i have user "root" in each cron command. " >/dev/null 2>&1" is not necessary, it just make sure cronjobs dont send out any error/nonerror emails.
*/1 * * * * is minutelly cron
58 * * * * is cron run every hour in 58th minute
If you have issue with crons, try to watch crontab logfile: /var/log/cron
# tail -n30 /var/log/cron