Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Need your help.

I need to run the CRON jobs on my local host as i am fetching feeds using RSS feeder. Please suggest how this can be achieved.

Thanks for your help.

share|improve this question

migrated from stackoverflow.com Nov 27 '10 at 19:27

This question came from our site for professional and enthusiast programmers.

add comment

3 Answers

Take a look to this simple manual. This explains you how Cron works and how to add tasks to your crontab.

EDIT

Asuming you are on GNU/Linux, edit your crontab:

$ crontab -e

And add at the end the following line to execute it every minute:

*/1 * * * * /usr/local/bin/php -q /route/to/your/script.php

Make sure that your php executable is in /usr/local/bin

share|improve this answer
    
thanks for your reply. –  gourav Nov 27 '10 at 16:48
    
Actually i need to run the CRON from my LOCALHOST. Please suggest how to achieve this. –  gourav Nov 27 '10 at 16:49
    
'crontab -e' will open the cron list for your username on your host. Assuming this is a Linux question. –  Sairam Nov 27 '10 at 17:09
add comment

If you can try to divide your problem into two, it might be easier to solve for you:
-Writing a script which fetches the rss feed and does whatever you want it to do
-Scheduling the run of that script using a cron job.

These two parts are usually independent of each other.

Are you already done with the first part? Do you have a script which can do the fetching?

If it is ready already. What type of script is it? Perl,python, something else?

UPDATE: So you want to call a PHP script on a schedule using cron jobs.

You'll probably get permission errors in your first tries, so chmod your php script to 0755.

Open up your terminal and try the code examples here.

Once you find a working command the first part is complete.

Now with the easy part.
Type crontab -e
Press insert

Let's say within the above examples the "wget http://www.domain.com/file.php" worked for you, then type in:
*/5 * * * * wget http://www.domain.com/file.php

In my terminal, I need to press esc-shift and press z two times to close the crontab. If it works for you too great. You will get one line output saying crontab installed. Job done. Every five minutes your php script will work.

share|improve this answer
    
thansk for your reply... –  gourav Nov 27 '10 at 17:07
    
i am done with the first part. need to Job schedule (CRON) to be done on my local Host. i was using PHP and MySQL. Please suggest how to go about –  gourav Nov 27 '10 at 17:09
add comment

if you're working on a Windows environment, the easiest way to achieve this would be to set up a scheduled task to execute the PHP script that will fetch your RSS data (using the php executable - see here)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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