When configuring cron job for system account, there are a few points to pay attention to:
Since system account usually does not have
home
directory, andcron
will attempt tochdir
to thehome
directory before executing the actual command, you are likely to get an error log in/var/log/cron
saying something like(CRON) ERROR chdir failed (/home/runcron): No such file or directory
Solution: edit the system account entry in/etc/passwd
to have thehome
directory set to/
(file system root)The default settings in
/etc/crontab
have a very limitedPATH
, which may cause your script to fail whencron
runs it.
Solution: either use full path in your script or set your ownPATH
at the beginning of your scripts(recommended)