This site requires JavaScript to be enabled
Welcome Guest|
Recent searches

How to fix broken user cron jobs in root

Number of views : 9
Article Number : KB0017189
Published on : 2019-11-27
Last modified : 2019-11-27 22:16:14
Knowledge Base : ESM External

*/5 * * * * echo $(date -u) >> /path/to/testlog.txt 2>&1; /usr/local/bin/ 2>&1 >> /path/to/testlog.txt | mailx -E -s “subject”

This is how I advise customers on creating their own cron jobs that need to run as root. I'll break down what it does.

1. echo $(date -u) >> /path/to/testlog.txt 2>&1; /usr/local/bin/ 2>&1 >> /path/to/testlog.txt | mailx -E -s “subject”

This part creates a date stamp, then appends it to a logfile, and suppresses stderr and stdout


2. echo $(date -u) >> /path/to/testlog.txt 2>&1; /usr/local/bin/ 2>&1 >> /path/to/testlog.txt | mailx -E -s “subject”

Then it runs the script, and appends all output (stderr and stdout) to the same log.

3. echo $(date -u) >> /path/to/testlog.txt 2>&1; /usr/local/bin/ 2>&1 >> /path/to/testlog.txt | mailx -E -s “subject”

This will then parse the output of that to email. The -E prevents it from sending a blank email if there is no content to send.







Permalink: utss/

Thank You! Your feedback has been submitted.