Editing crontab with php script?

software development

#1

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.


#2

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


#3

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.