1

I've got a binary file I want to execute every minute. I've opened up the cron config file by running crontab -e and added the following line:

* * * * * tutchi -logpath /home/user/path/logs/myfile.log

This did not work so I tried adding the full path to the binary

* * * * * /home/user/path/bin/tutchi -logpath /home/user/path/logs/myfile.log

But still does not work. I know the command I'm running is correct because if I just run /home/user/path/bin/tutchi -logpath /home/user/path/logs/myfile.log then everything runs fine. I also know that the cron tasks are working because I created a dummy one that runs every minute and echos something into a log file

I checked the log file and everything seems alright no errors other than my mail server not being set up

Oct 24 23:36:51 hairbuddy-notify cron[25522]: (CRON) INFO (pidfile fd = 3)
Oct 24 23:36:51 hairbuddy-notify cron[25522]: (CRON) INFO (Skipping @reboot jobs -- not system startup)
Oct 24 23:37:01 hairbuddy-notify CRON[25527]: (rodzz) CMD (/home/rodzz/hairbuddy/bin/tutchi -logpath /home/rodzz/hairbuddy/logs/tutchi.log)
Oct 24 23:37:12 hairbuddy-notify CRON[25526]: (CRON) info (No MTA installed, discarding output)
Oct 24 23:38:01 hairbuddy-notify CRON[25542]: (rodzz) CMD (/home/rodzz/hairbuddy/bin/tutchi -logpath /home/rodzz/hairbuddy/logs/tutchi.log)
Oct 24 23:38:13 hairbuddy-notify CRON[25541]: (CRON) info (No MTA installed, discarding output)
Oct 24 23:39:01 hairbuddy-notify CRON[26497]: (rodzz) CMD (/home/rodzz/hairbuddy/bin/tutchi -logpath /home/rodzz/hairbuddy/logs/tutchi.log)
Oct 24 23:40:01 hairbuddy-notify CRON[26955]: (rodzz) CMD (/home/rodzz/hairbuddy/bin/tutchi -logpath /home/rodzz/hairbuddy/logs/tutchi.log)
Oct 24 23:41:01 hairbuddy-notify CRON[26970]: (rodzz) CMD (/home/rodzz/hairbuddy/bin/tutchi -logpath /home/rodzz/hairbuddy/logs/tutchi.log)
Oct 24 23:42:01 hairbuddy-notify CRON[26980]: (rodzz) CMD (/home/rodzz/hairbuddy/bin/tutchi -logpath /home/rodzz/hairbuddy/logs/tutchi.log)
Oct 24 23:43:01 hairbuddy-notify CRON[26991]: (rodzz) CMD (/home/rodzz/hairbuddy/bin/tutchi -logpath /home/rodzz/hairbuddy/logs/tutchi.log)
Rodrigo
  • 133
  • A weird workaround, but try running the file with bash. – Rohitt Vashishtha Oct 24 '16 at 16:10
  • * * * * * bash -c "/home/user/path/bin/tutchi -logpath /home/user/path/logs/myfile.log" – Rohitt Vashishtha Oct 24 '16 at 16:12
  • @RohittVashishtha Unfortunately did not work – Rodrigo Oct 24 '16 at 16:40
  • There are several ways a command run from cron gets a different environment (in the larger sense, not just environment variables.) Many are listed in http://askubuntu.com/questions/23009/reasons-why-crontab-does-not-work . The one that has gotten me in the past is cron jobs get no stdin (fd 0 is closed), which will sometimes cause binaries to error out. – rfm Oct 24 '16 at 21:32
  • @rfm, I'm almost certain that it isn't closed; it is just connected to /dev/null rather than a terminal. – psusi Oct 25 '16 at 01:36
  • @psusi Actually reading the source, it's a pipe end. The parent cron process will write anything after a % on the crontab line into the pipe. (I never knew that!) – rfm Dec 04 '16 at 05:29
  • @rfm, that's a neat hidden feature! – psusi Jan 16 '17 at 03:29
  • @psusi can't really call it "hidden", it's right in the crontab(5) man page. – rfm Jan 17 '17 at 03:56

0 Answers0