I'm trying to create a scheduled task that runs a shell script recurrently, and I'm having some trouble getting it to work. I give it the following command to run every minute:


But it doesn't ever run. (This command runs the shell script through the terminal no problem.) Any ideas what I'm doing wrong? Thanks!

Note: Here's my shell script:

sleep 15
date >> output.txt
{ time ./foo > /dev/null ; } 2>> output.txt

And here's the cron line:

* * * * * /home/joe/Desktop/foo/my_script # JOB_ID_3
  • 1
    What scheduler are you using, and how do you know that it doesn't run? – PeterJCLaw Apr 6 '10 at 21:38
  • I'm using the scheduled tasks application from Applications -> System Tools -> Scheduled Tasks in the Ubuntu menu. I know it doesn't run, because the work isn't getting accomplished. I think this application uses cron, because I just ran the command 'crontab -e' and there's an entry for the task I created in scheduled tasks – John Kube Apr 6 '10 at 22:19
  • ah, please post the cron line. I suspect you've misunderstood (as I did at first) how it works. – PeterJCLaw Apr 6 '10 at 22:25
  • I posted it above :) – John Kube Apr 6 '10 at 22:28

The scheduler most likely doesn't know how to expand ~ try giving it an absolute path instead.

EDIT, after solution found:

Another idea I had was that maybe cron was ignoring the line due to all *'s, but I couldn't replicate this. I did find that it's man page is rather unhelpful, but that wikipedia's page on cron is somewhat useful. I was going to suggest using the line:

*/1 * * * * /home/joe/Desktop/foo/my_script # JOB_ID_3

as this would run at */1 (ie every minute that divides by 1) if it continued to fail.

| improve this answer | |
  • hmm, just tried this with cron and it seemed to work fine. – PeterJCLaw Apr 6 '10 at 21:37
  • I did, still doesn't work... – John Kube Apr 6 '10 at 21:38

I figured out the problem. Cron runs the tasks in the home directory, so that's where my output file is showing up. This is why I thought it wasn't running.

| improve this answer | |
  • That's why it's a good idea to always use absolute paths for files. – Paused until further notice. Apr 6 '10 at 22:42
  • This occurred to me, but I dismissed it as too simple an issue! Though I've fallen foul of this a number of times. The other thing I was going to suggest was that you check that it was +x, but it running correctly in shell suggested that this was also not the issue. – PeterJCLaw Apr 6 '10 at 22:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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