I have some commands, they are working under bash, but not as cronjob. To see, what cause the problem, i'm saving the output in a file, here my example:
51 * * * * source ~/.rvm/scripts/rvm >> stack.log 2>&1
The content of the log file is:
/bin/sh: 1: source: not found
That means, cron is using
sh insead of
bash. I've tried to change it in the
But this doesn't work. I've looked in the
/etc/passwd and here i see, that the daemon is using
sh as default shell. Both
bash as default shell.
root:x:0:0:root:/root:/bin/bash daemon:x:1:1:daemon:/usr/sbin:/bin/sh pi:x:1000:1000:,,,:/home/pi:/bin/bash
What should i do to change the default shell for cron? I wouldn't set
/bin/bash for the daemon user in
/etc/passwd...imho this is not a good idea.
ls -l /bin/sh lrwxrwxrwx 1 root root 4 Mar 30 2012 /bin/sh -> dash
here the content of the
# /etc/crontab: system-wide crontab # Unlike any other crontab you don't have to run the `crontab' # command to install the new version when you edit this file # and files in /etc/cron.d. These files also have username fields, # that none of the other crontabs do. SHELL=/bin/bash PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin # m h dom mon dow user command 17 * * * * root cd / && run-parts --report /etc/cron.hourly 25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily ) 47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly ) 52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly ) #
sourcein crons environment? Simply running the
~/.rvm/scripts/rvmdoesn't work? And you can have problems with using ~ in non-bash-environments.