0

I'm on an AWS server. I wrote a crontab and placed it on the server under /etc/cron.d. The contents of the crontab are the following:

SHELL=/bin/bash
PATH=/sbin:/bin:usr/sbin:/usr/bin
MAILTO=root
HOME=/

*/5 * * * * root <full-path-to-write-command> >> <full-path-to-txt-output-file>

After running sudo service crond restart, I check the logs by doing sudo tail -f /var/log/cron.

I can observe the cronjob in the logs:

<date-time-stamp> ip-<ip-address> CROND[12930]: (root) CMD (<full-path-to-write-command> >> <full-path-to-txt-output-file>)

However, when I check the <full-path-to-txt-output-file>, I don't see file being written to.

What could be the problem, if I see that the cronjob is executing? Thanks

makansij
  • 9,303
  • 37
  • 105
  • 183
  • Perhaps there is an error occurring. You aren't capturing STDERR in your log file, just STDOUT. You might try looking at this: http://stackoverflow.com/questions/7526971/how-to-redirect-both-stdout-and-stderr-to-a-file You might also try running `sudo ` to see what happens. – Mark B Sep 08 '15 at 21:52
  • I ran the command alone, as you suggest - it works just fine. – makansij Sep 08 '15 at 22:24
  • You might also look at this: http://unix.stackexchange.com/questions/49077/why-does-cron-silently-fail-to-run-sudo-stuff-in-my-script – Mark B Sep 08 '15 at 22:48
  • `/path/to/command >> /path/to/file 2>&1` otherwise you are discarding the error stream. – Michael - sqlbot Sep 08 '15 at 23:43
  • There is no error when I run the command, though. – makansij Sep 09 '15 at 01:12
  • Actually, this is a different issue entirely. Please see my new question: http://serverfault.com/questions/721042/empty-events-for-aws-vpc-logs – makansij Sep 09 '15 at 01:13

0 Answers0