I wrote a script that gets the crontab info, makes some changes, saves them 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 beautifully on the command line and then completely fails when I try to run it from a webpage. Does anyone have any idea why that is?

    Probably because when executed via the web it is executed as the webserver user instead of your login user account.

      I was thinking that. Crontab has a flag that lets you specify a user.

      exec('crontab -u myuser -l');

      But when I use that on the command line I get a debug error saying "must be privileged to use -u". Nothing decernable happens when I use the -u flag on a web page. I imagine that there may be some errors that aren't comming through to the web page, though. How can I redirect them to the html output?

        4 days later

        sudo might work, I'm just not too familliar with it yet. I would have to give the user 'nobody' permission to access cron as my personal user, right? is that dangerous?

          Write a Reply...