I have some shell code that I'd like to execute daily using cron. Currently, I have the entire code written as a one-liner, and the 6 variations (each designed to run at different times) are all written in the crontab. While this works, it's quite difficult to read, and could be made more efficient by putting the code in a shell script, and running the script with cron.
However, I need to put the script somewhere. I cannot find anything in the man pages or online specifying the 'proper' location for cron jobs. Is there a directory in /etc
for cron jobs? Or should I use root permissions to put my script in /usr/lib/cron/jobs/
? Should I put the script in ~/.bin/
and use the full path in my crontab?
When I ask where I 'should' put it, I am looking for the location that is designated by the implementation of cron, or, if that doesn't exist, the location that makes the most sense and is most secure.
Note: the script needs no special permissions, just to run as me.
cron
, it states: "The cron utility is launched by launchd(8) when it sees the existence of /etc/crontab or files in /usr/lib/cron/tabs." and at the bottom is states: "/usr/lib/cron/tabs Directory for personal crontab files". As far as shell scripts, see the answer from nohillside.