Editing crontab with php script?

Editing crontab with php script?

Posted by: zachrose
Posted on: 2009-01-25 16:50:00

Hi all. Can anyone tell me how to add new cron jobs with PHP? I'm having a hard time figuring out where to start with this.

Re: Editing crontab with php script?

Posted by: Braunson
Posted on: 2009-02-04 13:16:00

Hello,

I dont believe you can add them with PHP, you need to login via SHELL or via the Dreamhost Panel -> Goodies -> Cron Jobs.

Best Regards,
Braunson

Re: Editing crontab with php script?

Posted by: netdcon
Posted on: 2009-02-10 09:48:00

In reply to:

Hi all. Can anyone tell me how to add new cron jobs with PHP? I'm having a hard time figuring out where to start with this.


Caveat: Make sure you're aware of DH's usage policies regarding this sorta thing before embarkation.

But *anyway*, a loose idea...
Use PHP to read and import the current crontab contents using the "exec" function to do a UNIX "crontab -l" and pop it into a text variable. Pop that into an HTML "textarea". Edit the contents, then submit to a PHP form processor that exports the "textarea" contents using "exec" and a plain "crontab" command (without the " -l") to update your cron.

Note: I haven't done this myself, but it should work just fine and shouldn't be that much of a challenge for a mildly experience PHP person.

Tags: cron jobscrontabhard time