Ubuntu Server 14.04 LTS, and I've got the following in a crontab:

00 06 * * 1-5 /usr/local/bin/scribe /etc/local/scribe.1.conf 1&2>> /var/log/local/scribe.1.log
00 15 * * 1-5 killall scribe; sleep 10; /usr/local/bin/scribe /etc/local/scribe.1.conf 1&2>> /var/log/local/scribe.1.log
15 16 * * 1-5 killall scribe

My intention here is to run a program at 6am, kill it at 3pm, and re-run it at 3:00:10pm. What I'm seeing is the log file being created, but remaining empty and never being written to. The user whose crontab this is has write permissions to the log directory, so I'm not sure why the log file remains empty. I have to assume I've made a syntax error or so.

  • 1
    What shell is this? your redirection looks suspect to me: did you perhaps mean >> /var/log/local/scribe.1.log 2>&1? – steeldriver Jul 6 '16 at 19:12

The ... 1&2>> ... is viewed as ... 1& and then 2>> ....

In other words, it starts the first part in the background, creates a log file, and try to start 2 which certainly does nothing. So no output is sent to that log file.

I usually do something like 2>&1 to say to send stderr to stdout. You have to define stdout first if you want the errors and standard output to go to the same file. So something like >>blah.log 2>&1.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.