0

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.

pdm
  • 165
  • 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 06 '16 at 19:12

1 Answers1

4

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.

Alexis Wilke
  • 2,857
  • I've changed the crontab and will report back with success or failure tomorrow. =) – pdm Jul 06 '16 at 20:43
  • 1
    non-posix, but in bash you can use >& blah.log instead of >>blah.log 2>&1. http://unix.stackexchange.com/questions/70963/difference-between-2-2-dev-null-dev-null-and-dev-null-21 – cas Jul 07 '16 at 07:39