0

I have a bash script that needs to be executed everyday at 9:30pm. its called fetchIND.sh and I've made the entry for that in my tab with specifying the shell and path parameters as follows. It is supposed to fetch files off another server with sftp and works just fine manually. However, with crontab is doesn't execute.

My crontab entry :

06 21 * * * root /usr/bin/bash /root/IND/fetchIND.sh

results after 'ps aux | grep bash' command:

root 5815 0.0 0.0 8984 808 pts/0 S+ 21:06 0:00 grep --color=auto bash

However, my script doesn't actually execute. Any help regarding this would be great. Thanks!!

Vedant7
  • 71
  • 1
  • 1
  • 6

2 Answers2

0

The cron might be trying to run this in cron shell which might not have permission for running the command in root shell.

Adding sudo might do the work. Refer to this for more https://superuser.com/a/1046126

0

(Edited out a suggestion to check syntax -- this seems to be valid for CentOS. Leaving other suggestions, added details. -- sorry I have not enough karma to comment, hehe)

Your script might depend on things that are different when invoked by cron daemon: environment variables that you might have altered in your shell, access to a tty, etc.

You can debug it by appending a redirection:

06 21 * * * root /usr/bin/bash /root/IND/fetchIND.sh 2>&1 >> /tmp/trace_when_running_from_crontab.log
Hugues M.
  • 17,453
  • 5
  • 27
  • 56
  • Hey. The reason 'root' is present is because my crontab asks to specify the username before the command. I'm working with Cent OS so the format's probably different – Vedant7 Apr 02 '17 at 08:35