Re: Crontab

From: Date: Thu, 11 Jan 2001 15:00:45 +0000
Subject: Re: Crontab
References: 1 2  Groups: php.general.es 
Request: Send a blank email to general-es+get-5707@lists.php.net to get a copy of this message
Patxi Echarte Ayerra wrote: > > Creo que no he explicado bien cual era mi problema. Lo que deseo hacer es lo > siguiente: > Tengo digamos 5 scripts de manteinimiento que hay que ejecutar de forma > periódica. Esta periodicidad la tiene que elegir el administrador del web, Umm... a ver que tal así: /etc/crontab.orig -------------- SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root HOME=/ # run-parts 01 * * * * root run-parts /etc/cron.hourly 02 4 * * * root run-parts /etc/cron.daily 22 4 * * 0 root run-parts /etc/cron.weekly 42 4 1 * * root run-parts /etc/cron.monthly /home/httpd/www/admin/crontab.web ------------------------------ 01 * * * * nobody miscript_admin1.sh 02 * * * * nobody miscript_admin2.sh 03 * * * * nobody miscript_admin3.sh ... /etc/con.hourly/modifica_cron.sh -------------------------------- #!/bin/bash webcron="/home/httpd/www/admin/crontab.web" if [ -f $webcron ]; then cat /etc/crontab.orig $webcron > /etc/crontab /etc/rc.d/init.d/crond restart rm -f $webcron fi Desde la web con php escribes el fichero /home/httpd/www/admin/crontab.web, fijandote que escribes bien los formatos de las horas, el script a arrancar, etc. En script "modifica_cron.sh", cada hora testea si ese fichero existe, en cuyo caso, lo que hace es concatenar el fichero "crontab.orig" y "crontab.web" y con eso crear un nuevo fichero /etc/crontab. Despues se reinicia el demonio del cron (este paso creo que no es necesario ya que crond debería detectar que el crontab ha cambiado) y acabar borrando el "crontab.web" original. Explicado asi, parece mas largo de lo sencillo que es en realidad. A ver si te sirve. Saludos, Tomas V.V.Cox

« previous php.general.es (#5707) next »