Reputation: 337
I'm new to cron jobs. I read a post on how to write a cron job with crontab. So my crontab looks like this:
1 * * * * /Users/apple/Desktop/wget/down.sh
which basically means that every minute i want to execute the script :down.sh. Now the script runs fine manually. The script is a simple program that downloads a PDF from the internet:
#!/bin/bash
wget -U Mozilla -t 1 -nd -A pdf "http://www.fi.usj.edu.lb/images/stories/HoraireS08/3eli.pdf" -e robots=off;
I don't know why it's not running every minute once the terminal tells me that he's installing the new crontab.
Can somebody help me please?
Solution: Thank you all for your help, the syntax as mcalex said should be * */1 * * * path/to/script if you want it to be executed every hour. The cron job was working normally.However my mistake was simply writing permissions, in fact while executing the wget command, it's supposed to write the pdf file in the current workind directory which is a system directory in case of the cron tab. so i solved my problem simply by navigating to the Desktop directory before executing the wget command like so:
cd /Users/apple/Desktop/wget
and then do whatever i want to do. PS: i should include the full path of the wget command too.
Thank you all for you help again:)
Upvotes: 11
Views: 30584
Reputation: 1654
If your cronjob is writing things to disk then be careful that system preference "Put hard disk to sleep when possible" is unchecked.
This was preventing my cronjob backup tasks to execute.
Upvotes: 4
Reputation: 6778
When you put 1 in the first column, it will run on the first minute (of every hour). In order to get it to run in every minute of every hour, you need to set the minute column as */1
So your line should read:
*/1 * * * * /Users/apple/Desktop/wget/down.sh
supporting links:
job every minute: https://bbs.archlinux.org/viewtopic.php?id=59180
job every 5 minutes: http://www.thegeekstuff.com/2011/07/cron-every-5-minutes/
Upvotes: 17
Reputation: 89
1 * * * * /Users/apple/Destop/wget/down.sh
From this entry script will never run on every minute because it will run on first minute of every hour.
Make this change to your crontab file to run this script every min.
"* * * * * /Users/apple/Destop/wget/down.sh"
Upvotes: 7
Reputation: 6060
Do you have a typo? It looks like you might have mis-typed Desktop?
Another thing to do is to redirect the output of running the script to a file so you can see what's going on like this:
1 * * * * /Users/apple/Destop/wget/down.sh >> /tmp/cron.out
and then check out the file to see what's going on.
Upvotes: 5
Reputation: 72657
/bin/sh
to execute commands.PATH
in your script? wget
may not be in the default PATH
or there may be no PATH
at all. Try using /path/to/wget
in the script.Note that downloading the same PDF file once a minute is probably a silly idea, though...
Upvotes: 4