Linux.com

cron running scripts

Link to this post 25 May 09

Hi. I've been reading about cron and I think it's a pretty useful utility. However, I've had a bit of trouble with it running scripts.

I'm running Ubuntu 9.04 with Gnome, by the way.

For example, if I put the following line into my crontab

* * * * * ~/script
(I've tried variations of this using the full path to the script and the $HOME variable.)

And I wait a minute or so, nothing happens. In the System Log Viewer an entry in syslog is added every minute saying that the script was being run, but nothing actually happens. I tried redirecting the output to a file, but the file is blank after the script is run. No errors are shown. I tried "sudo chmod a+rwx" on the script (just in case the script wasn't being run due to permissions issues) but it still isn't working...

Crontab works for other things though. I use it as an alarm clock with

30 5 * * * export DISPLAY=:0 && firefox pandora.com

...and it works as expected.

I'm confused as to why I can't seem to get the program to run the script, or failing that give any sort of error message.

My script, by the way, isn't that complicated, and it works properly when running it regularly...

#!/bin/bash
git add .
git commit -m "Commit on `date`"


Has anyone dealt with this issue before? Any help would be appreciated. :)

~Dennis

Link to this post 25 May 09

have you tried telling cron to run it as a shell script?

* * * * * sh ~/script

Link to this post 25 May 09

or you have to cd to the right directory first (in the script)?

Link to this post 25 May 09

@bastib I tried a couple of different scripts using full path names; none of them run.

I tried doing
#!/bin/bash
touch /home/dennis/testing

And it doesn't run.

@mfillpot I just tried it with the sh in front. It still doesn't work. :(

Link to this post 25 May 09

what output do you get when you try to run the contents of script or the script itself within a terminal?

Link to this post 25 May 09

@mfillpot

When I run it from the terminal it works fine.

Created commit 0c2664e: Commit on Sun May 24 10:58:40 EDT 2009
1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 .gitignore

Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board