Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

crontab is not running my script

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:)

like image 476
Elie Avatar asked Nov 08 '12 00:11

Elie


3 Answers

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/

like image 99
mcalex Avatar answered Oct 25 '22 08:10

mcalex


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.

like image 26
Manel Avatar answered Oct 25 '22 10:10

Manel


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.

like image 32
Classified Avatar answered Oct 25 '22 09:10

Classified