I am trying to set up a cron job, by creating a file
55 * * * * t echo hello > /tmp/cron.log && cd /tmp/test/ && pwd > /tmp/cron.log
I tried to verify if the job is scheduled successfully, by using the redirections. I created the file at 21:50, and when 5 minutes later i.e. it is 21:55, there is still no /tmp/cron.log created. I was wondering why?
I specify the user to be
t for the job in
/etc/cron.d/myjob. But whose is the cron job? I am not sure about it, so I tried the two commands below. Neither shows the job I created.
$ crontab -l no crontab for t $ sudo crontab -l [sudo] password for t: no crontab for root
My /etc/crontab doesn't explicitly read from the files under /etc/cron.d/. See below. Can that be the reason that my cron job isn't running? Thanks.
# /etc/crontab: system-wide crontab # Unlike any other crontab you don't have to run the `crontab' # command to install the new version when you edit this file # and files in /etc/cron.d. These files also have username fields, # that none of the other crontabs do. SHELL=/bin/sh PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin # m h dom mon dow user command 17 * * * * root cd / && run-parts --report /etc/cron.hourly 25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily ) 47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly ) 52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly ) #
Thanks to Jeff. change permission on
rw-r--r-- solves the problem.
Why does the original
rw-rw-r-- permission of my job file not work, but
rw-r--r-- is required? Do the files under
/etc/cron.daily/ must have the same permissions
/etc/crontab not need to explicitly read the files under