Cheatsheets:
programming:
How-to:
Troubleshooting:
Rants:
Other:
Cheatsheets:
programming:
How-to:
Troubleshooting:
Rants:
Other:
This is an old revision of the document!
If the cron service on your MacBook has stopped working, here are some steps you can take to troubleshoot the issue:
ps command to check if the cron service is running. Type ps aux | grep cron in the terminal to see if the cron service is currently running. If it's not running, you may need to start it manually.tail -f /var/log/system.log in the terminal. This will show you the last few lines of the system log in real-time. Look for any messages related to cron, such as errors or warnings.crontab -l in the terminal to view the contents of your crontab file. Make sure that the syntax of your cron job entries is correct, and that they are scheduled to run at the correct times.ls -l /usr/sbin/cron in the terminal to view the permissions of the cron binary. It should have the permissions -rwxr-xr-x (read, write, execute for the owner; read and execute for group and others). Similarly, check the permissions of the crontab files by typing ls -l /usr/lib/cron/tabs.sudo launchctl unload /System/Library/LaunchDaemons/com.vix.cron.plist to stop the cron service, and then type sudo launchctl load /System/Library/LaunchDaemons/com.vix.cron.plist to start it again.yes, as expected once for root, and once for the local user:
$ ps aux | grep cron root 457 0.0 0.0 408113488 1056 ?? Ss Tue06PM 0:00.51 /usr/sbin/cron kamaradski 37314 0.0 0.0 408628368 1632 s013 S+ 5:17PM 0:00.00 grep cron
no:
$ cat /var/log/system.log | grep "cron"
However, this is not a good thing as i would expect also a note when crons are getting executed successfully
$ crontab -l 0 6 * * * cd /Users/kamaradski/00-automation/script1 && go run main.go 5 6 * * * cd /Users/kamaradski/00-automation/script2 && go run main.go
Can we run the command from our current user? ⇒ yes:
$ cd /Users/kamaradski/00-automation/script1 && go run main.go 12345689%
Hmm just to be sure let me point it to the exact go bin that we want to use, who knows?
$ which go /opt/homebrew/bin/go $ crontab -e crontab: installing new crontab $ crontab -l 0 6 * * * cd /Users/kamaradski/00-automation/script1 && /opt/homebrew/bin/go run main.go 5 6 * * * cd /Users/kamaradski/00-automation/script2 && /opt/homebrew/bin/go run main.go
And yay what do you know: this fixed my issue :)
By default, the /usr/lib/cron/tabs/ directory should have a file mode of 755 and an owner of root. The files in the directory should have a file mode of 644 and an owner of root. This means that only the root user can modify the files, but any user on the system can view the contents of the files.
$ ls -l /usr/sbin/cron -rwxr-xr-x 1 root wheel 205440 Jan 11 08:03 /usr/sbin/cron sudo ls -l /usr/lib/cron/tabs Password: total 8 -rw-------@ 1 root wheel 420 Feb 25 17:40 yourusername
This is fine, my particular issue was already fixed in the previous step, however, if your issue is still happening you can always try edit this file to 644 and test again.