This question already has an answer here:

Anybody any suggestions on why my crontab and shell script is not running.

I have

chmod +x my shell script and added the following into crontab -e

*/5 * * * * bash cd /home/jclark/scrips/ipcheck/ && ./ipCheck.sh

ipCheck.sh then costits of the following:

curl http://api.externalip.net/ip/ -o ipRecord.txt

Although it doesn't appear to be running?

marked as duplicate by Florian Diesch, user76204, rɑːdʒɑ, stephenmyall, qbi Mar 6 '13 at 23:05

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Curious, what are you doing with ipRecord.txt? – user8290 Dec 30 '12 at 14:56

You can't run bash commands like that. Bash expects a file (a shell script) .as its argument.

You might be able to run the desired command like this:

*/5 * * * * bash -c "cd /home/jclark/scrips/ipcheck/ && ./ipCheck.sh"

Note the -c and the quotes around the commands you want to execute.

I think that what you actually want is:

*/5 * * * * /home/jclark/scrips/ipcheck/ipCheck.sh

... and the script should contain:

curl http://api.externalip.net/ip/ -o /home/jclark/scripts/ipcheck/ipRecord.txt
  • Thanks for the answer, the damn thing still doesn't seem to run! – user117262 Dec 28 '12 at 16:45
  • @JacobClark Works for me on Ubuntu 12.10 exactly as I wrote it after the "what you actually want" part. – user39051 Dec 28 '12 at 16:51
  • by running crontab -e? – user117262 Dec 28 '12 at 16:52
  • @JacobClark Yep crontab -e is how I edited the crontab. I added it to the crontab, waited till the clock hit the right time, then checked and saw that the file was updated. Note that if you edit your crontab only a minute or two before it's supposed to trigger a job, the job probably won't be triggered. Wait another 5 minutes. – user39051 Dec 28 '12 at 16:59
  • I have done exactly has shown but my Ubuntu 12.04 Rackspace Cloud Server just isn't running it – user117262 Dec 28 '12 at 17:18