I’m quite new to cron and crontab.
I’ve edited the crontab file and I need to execute manually one of commands so I can try it and test it beforehand. How do I do that? If it fails, is there a mode that shows the errors?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
cronprovides barely any environment – so your script may have to fix that. In particular, your profile will not be used.No, there isn’t specifically a mode that shows errors. Usually, if the cron job witters, the output is emailed to you. That is, it sends standard output and standard error information to you if the executed command writes anything to either standard output or standard error.
On MacOS X (10.6.7), the environment I got was (via a
crontabentry like12 37 17 5 * env >/tmp/cron.env):Of those,
PWD,_andSHLVLare handled by the shell. So, to test your script reliably in a cron-like environment, use:The
-ioption toenvmeans ‘ignore all inherited enviroment’; the script will see exactly the five values specified plus anything the shell specifies automatically. With no arguments,envreports on the environment; with arguments, it adjusts the environment and executes a command.