Jump to content

modifying crontab with php


sing1ejack

Recommended Posts

I have a script that gets the crontab info, makes changes, saves it in a temp file and updates crontab with it.

 

exec("crontab -l", $crontab);
<< make changes to $crontab array >>
<< write array to tempfile.txt >>
exec("crontab ".$filename);

 

It works like a dream on the command line and fails completely when I try to run it from a webpage.  Any idea why?

Link to comment
https://forums.phpfreaks.com/topic/39528-modifying-crontab-with-php/
Share on other sites

when you run it from the command line you are root.

 

When browse to it, apache is running the command, and apache does not have permission to update root's crontab.

 

Try doing a:

 

echo system('whoami');

 

There is a command to execute things as root (google for it) but i don't know how safe that'd be allowing apache to do root stuff. Be careful  :o  :o  :o

 

hope that helps  :)

 

monk.e.boy

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.