0

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?

1 Answers1

2

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