DreamHost Web Hosting
Discussion Forum


Forums
   >> Programming
*Threaded Mode

Subject Cron Jobs?  
Posted byoffcampus (DH New User )
Posted on08/16/06 10:35 AM



Is there a good guide that shows how to setup a cron job on dreamhost to run a php file at a certain time everyday?

Thanks in advance for the help!!

-Rob

Apartments for Rent and Roommates | National Parks and Camping Reviews | NCSU Apartments


Subject Re: Cron Jobs? new [re: offcampus]  
Posted bygordaen (DH Enthusiast)
Posted on08/16/06 10:51 AM



Basic format:

* * * * * bash /home/USERNAME/file.blah

The asterisks are:
Minute (0-56)
Hour (0-23)
Day of Month (1-31)
Month (1-12 or name (e.g. "May"))
Day of Week (0-6, zero being sunday, also can write "sun" for sunday etc.)

For instance:

15 5 * * * bash /home/USERNAME/myheadin.sh

Will "bash myheadin.sh" at 5:15am every day (* is a wildcard).

Though, to answer your question, I'd bet there is a good guide out there somewhere.

Note: For php files, just replace bash with php in the example.
Also note: After the time entries you do NOT need the username on DH (compared to if you were using your own linux box).

Check out Gordaen's Knowledge, the blog, and the MR2 page.


Subject Re: Cron Jobs? new [re: gordaen]  
Posted byubermondo (DH Dreamling)
Posted on08/17/06 10:27 AM



Good deal -- I want to schedule "rake clear_logs" as a cron job. Do I need to wrap this in a shell script?



Subject Re: Cron Jobs? new [re: ubermondo]  
Posted bygordaen (DH Enthusiast)
Posted on08/17/06 12:42 PM



No, you should be able to run straight commands just fine with Cron. You can also add

MAILTO=youremail@wherever.com

to the crontab so that it will e-mail the output of each job to you. That's especially useful when you are first testing Cron jobs. Just be sure to use full directories or variables for the paths. You could add it to a .sh if you wanted to add some extra output text or information for your own benefit.

Check out Gordaen's Knowledge, the blog, and the MR2 page.


Subject Re: Cron Jobs? new [re: gordaen]  
Posted byubermondo (DH Dreamling)
Posted on08/17/06 01:05 PM



Good deal -- thanks!




*Threaded Mode
Jump to