Adjective: Comparative form of nerdy: more nerdy.

Debugging cron

I had an issue where cron was running but my command wasn’t working but it worked when I ran it manually.

Best way to do this is to add “2>&1 | logger” to the end of the command, this redirects all the output to syslog.

Edited my crontab:

7,37 * * * * /usr/bin/puppet agent --no-daemonize --onetime 2>&1 | logger

Wait for it to run, then check syslog:

Sep 11 15:22:01 server-xxx root: /usr/bin/env: ruby_noexec_wrapper: No such file or directory

Then fix your issue!

Mine was due to puppet being installed a gem, so I updated the path in /usr/bin/puppet to point to the correct ruby.

[root@server-xxx ~]# head -n 1 /usr/bin/puppet 

Once fixed you can remove the logger bit from the cron.


Leave a Reply

Your email address will not be published. Required fields are marked *