5 Replies Latest reply: Sep 26, 2012 8:19 AM by Dude! RSS

    different behaviour command line vs. cron

      OL 5.6 x86-64

      Yeah, I know what you're thinking already. Job from cron don't inherit the owner's environment. But in this case I don't see where that is a factor .... maybe.

      Given this command:
      chmod 777 /home/estevens/*.fil >/home/estevens/chmodlog_`date +%H%M`.lis 2>&1
      fine at my command shell, but when run from cron:
      * * * * * chmod 777 /home/estevens/*.fil >/home/estevens/chmodlog_`date +%H%M`.lis 2>&1
      output gets intercepted by mail and sends me this message:
      /bin/sh: -c: line 0: unexpected EOF while looking for matching ``'
      /bin/sh: -c: line 1: syntax error: unexpected end of file
      So, I'm not running a script that is depending on some env settings, but a simple command. The only thing I can think of that might impact is that my default shell is bash, but the error coming back indicates cron is using /bin/sh instead. I've never played around with trying to invoke different shells for specific tasks. And notice this:
      estevens:dwdev$ cat /etc/crontab
      # run-parts
      01 * * * * root run-parts /etc/cron.hourly
      02 4 * * * root run-parts /etc/cron.daily
      22 4 * * 0 root run-parts /etc/cron.weekly
      42 4 1 * * root run-parts /etc/cron.monthly