D&C GLug - Home Page

[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]

Re: [LUG] PHP or Perl script to edit crontab from browser

 

> I'm trying to implement a simple web based solution for setting up cron
> jobs via a web browser.  I was wondering if anyone had come across a PHP
> or Perl script to do such a thing?
>
> What I want is for the user to load a web page on a linux box, select an
> option of what they want to happen and what time (from a predetermined
> list of times and commands) and then have it save the details to the
> crontab file.
>
> Is this possible or would I be better off having some sort of PHP/Perl
> script set to run every minute to check the time and if it matches in a
> file to then run some commands?

I think it should be possible, at least in perl, to edit the cron file
from a script on a website, but I suspect some security issues.
Moreover, you'd have to read from the cron file, translate the output
into something your Perl/PHP script understands, make the changes and
write it back into the cron file. That's four steps where something
could go wrong. Imagine for example if someone with access to the
linux machine just edits the cron file via crontab -e, adds a few
harmless lines, with the effect of your translation script getting
very confused. It's just one of the things that could go wrong.

I think it makes more sense to store the 'cron jobs' in a database
somewhere and, indeed, run one master cron job that runs every minute
and checks from the database which commands need to be executed at
that time. If you write it well, it'll give you a lot of flexibility.

HTH.

Martijn.

-- 
The Mailing List for the Devon & Cornwall LUG
http://mailman.dclug.org.uk/listinfo/list
FAQ: http://www.dcglug.org.uk/linux_adm/list-faq.html