I'm currently looking to understand and get comfortable with crontab queues on my macbook pro. I recently solved an issue where my simple bash script would not execute. It turns out I had to move my bash script and its output in the /Users/myusername/
path. Before I had it in the /Users/myusername/Desktop/
. This post can be found here – https://stackoverflow.com/questions/64110897/simple-bash-script-doesnt-cron-properly?noredirect=1#comment113370465_64110897
My question: Do all of my bash and python scripts need to be housed in /Users/myusername
path always? Is there no workaround?
Best Answer
Question:
Answer:
No. You can locate your bash and python scripts anywhere you like. However, there are additional requirements:
cron
jobs run with a different ENVIRONMENT than when you run them; e.g.$PATH
. Consequently, you should use a full path specification for specifying your scripts in thecrontab
; for example use:cron
. YMMV on a different OS version. Here's how:System Preferences
->Security & Privacy
->Privacy
tab:cron
job, you should consider redirecting any error messages (stderr
) to a file - otherwise they wind up in/dev/null
which is not helpful! Continuing with the above example: