I've been scouring the internet for a solution, but I have a shell script I want to run that works fine from the cli but not from cron.

This works from my prompt: sh ~/Applications/scripts/script.sh

crontab entry:

* * * * * /home/user/Applications/scripts/script.sh

script looks as follows:

/usr/local/bin/myapp update &> /home/user/myapp_sh_update_stdout.log
/usr/local/bin/myapp run &> /home/user/myapp_sh_run_stdout.log

Thoughts? Experiments with other answers are no good for me, so I am going specific to see what I could do differently. Running it every minute to debug, but it will be run at a morning hour on one day of the week when confirmed working.

  • You need user there. * * * * * root /home/user/Applications/scripts/script.sh – Pilot6 Mar 9 at 16:35
  • @Pilot6 just to be clear, that's only the case for the system-wide /etc/crontab – steeldriver Mar 9 at 16:39

&> is a bashism - either change the shebang to #!/bin/bash or change the redirections to

/usr/local/bin/myapp update > /home/user/myapp_sh_update_stdout.log  2>&1
/usr/local/bin/myapp run > /home/user/myapp_sh_run_stdout.log 2>&1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.