October 06, 2008

put wget on the crontab

I've made email notication program using PHP. It works well if I run into browser, this is the url:

http://10.22.254.100/alert_email/msc.php

It also works well if I run using wget (one of unix command), this the unix command:

wget http://10.22.254.100/alert_email/msc.php

I need to schedule email notification, so its could send email automatically when I set the time. To do this kind of work, I use crontab. After, read some website on the internet. I do these:

1. create text file. I named it "stockcron". The content of the file is like this:

0 4 * * 1,2,3,4,5 wget http://10.22.254.100/alert_email/msc.php

2. Invoke the crontab command:

crontab stockcron

When the time come, my email notification program should send email automatically. But, don't know why Its didn't work. Argh...But don't worry guys n gals. I've got the solution. It took me few days to get the solution. Hold on thigh.....here's come the solution:

1. create file, I named it "email_cron_tes.sh". The content of the file is like this:

wget http://10.22.254.100/alert_email/msc.php

2. add this text on the crontab:

46 13 * * * /usr/bin/csh -c "(source /home/zul/.cshrc;/home/zul/email_cron_tes.sh)" > /dev/null 2>&1

The concept for this solution is the crontab will run your file "email_cron_tes.sh" in command prompt. Okeh...good luck guys n gals :)

No comments: