Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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:

#!/bin/sh
curl http://api.externalip.net/ip/ -o ipRecord.txt

Although it doesn't appear to be running?

share|improve this question

marked as duplicate by Florian Diesch, Mik, AgentCool, Stephen Myall, 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

1 Answer 1

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:

#!/bin/bash
curl http://api.externalip.net/ip/ -o /home/jclark/scripts/ipcheck/ipRecord.txt
share|improve this answer
    
Thanks for the answer, the damn thing still doesn't seem to run! –  Jacob Clark 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? –  Jacob Clark 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 –  Jacob Clark Dec 28 '12 at 17:18

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