How to set cron for a drupal site

Key words and phrases: 
setup cron drupal command line
Description & Info: 

So you've got yourself a drupal site and you're super tired of running cron by hand every day, or every time you want to refresh your news feeds or whatever...

Maybe you like running cron manually all the time, if so, stop reading now and go get a muffin...

Anyway, here's how to do it in a few easy steps, aka the agaric way...

First, go to your command line and type:

sudo crontab -l

That'll show you what's already scheduled to run...

Then, type:

sudo whereis wget

To confirm the location of wget --> probably, /usr/bin or something

Finally, type:

sudo crontab -e

This will open up a file and you'll probably see at least a line showing you the proper syntax for running cron...

anyway on a new line for each site you want to run cron on, use this:

45 * * * * /usr/bin/wget -O - -q http://www.example.com/cron.php

Make sure you save the file with ctrl+O then hit ctrl+x to exit..

Thats it! cron will run at 45 minutes past the hour on every site you setup...

Referenced:

http://drupal.org/node/31549
http://kevin.vanzonneveld.net/techblog/article/schedule_tasks_on_linux_u...

by Dan
Posted on Thu, 2007-10-04 23:09
in
Awesome Dan! A user

Awesome Dan!

A user interface someday to look and maybe set what cron we have for every site, but crontab -l (that's a lowercase L if you aren't copy-pasting) sure isn't hard.

We do want to be able to set cron from a bash script, Agaric's addsite script. Crontab seems to be an actual file (can't find it though) so there should be a way to pipe output to be added to the end of it... (to be continued)

And the whereis command is so much better than locate at actually finding what you need! Great work Dan!

Posted by Benjamin Melançon on Fri, 2007-10-05 12:05
how to tell cron to run on a

how to tell cron to run on a file on the server?
Dan Hak: i assume you can tell cron to run whatever command you want on a recurring basis
I3IVIIVI: do you remember what's typed? or if you documented? just to get into cron?
Dan Hak: yea I documented that I m sure
[Agaric's page here didn't answer, but]
I3IVIIVI: bloody hell we just have to put it in the directory labeled "hourly"

Posted by Benjamin Melançon on Fri, 2007-11-16 14:56
more good info

#Run command at 7:00am each weekday [mon-fri]
00 07 * * 1-5 mail_pager.script 'Wake Up'

#Run command on 1st of each month, at 5:30pm
30 17 1 * * pay_rent.script

#Run command at 8:00am,10:00am and 2:00pm every day
00 8,10,14 * * * do_something.script

#Run command every 5 minutes during market hours
*/5 6-13 * * mon-fri get_stock_quote.script

#Run command every 3-hours while awake
0 7-23/3 * * * drink_water.script

do it! the agaric way... (example below)

#Run cron every 5 minutes...
*/5 * * * * /usr/bin/wget -O - -q http://www.example.com/cron.php

got it?

good.

Posted by Dan on Thu, 2008-06-19 19:25
Post new comment
The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockquote> <h1> <h2> <h3> <h4> <h5> <h6> <small> <pre> <strike> <sub> <sup>
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
  _  _      ____   _____   ____    _   _ 
| || | / ___| |___ | | _ \ | | | |
| || |_ | | _ / / | |_) | | |_| |
|__ _| | |_| | / / | __/ | _ |
|_| \____| /_/ |_| |_| |_|
Enter the code depicted in ASCII art style.