Quantcast
Channel: Why crontab scripts are not working? - Ask Ubuntu
Viewing all articles
Browse latest Browse all 48

Answer by Ian Mackinnon for Why crontab scripts are not working?

$
0
0

In many environments cron executes commands using sh, while many people assume it will use bash.

Suggestions to test or fix this for a failing command:

  • Try running the command in sh to see if it works:

    sh -c "mycommand"
  • Wrap the command in a bash subshell to make sure it gets run in bash:

    bash -c "mybashcommand"
  • Tell cron to run all commands in bash by setting the shell at the top of your crontab:

    SHELL=/bin/bash
  • If the command is a script, make sure the script contains a shebang:

    #!/bin/bash

Viewing all articles
Browse latest Browse all 48

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>