starting and stopping system services based on time
Normally, services are started during the boot process when the system
transitions into the appropriate run level.
I want to stop and start one of two of these services using cron, and
I'm just querying for a preferred method.
Let's say, for example, I am the only user of a system, and I want
fetchmail to start automatically in run levels 3 and 5 but only between
the hours of 0700 and 1700 during weekdays.
From my home account I can add a crontab entry:
0 7 * * * 1-5 sudo /sbin/rcfetchmail start
0 17 * * * 1-5 sudo /sbin/rcfetchmail stop
Or I can add it to /etc/crontab:
0 7 * * * 1-5 /sbin/rcfetchmail start
0 17 * * * 1-5 /sbin/rcfetchmail stop
A third way is to write a short script and put it into /etc/cron.hourly
--
Jerry Feldman
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 The Sunday 2006-01-08 at 14:02 -0500, Jerry Feldman wrote:
Normally, services are started during the boot process when the system transitions into the appropriate run level. I want to stop and start one of two of these services using cron, and I'm just querying for a preferred method.
Let's say, for example, I am the only user of a system, and I want fetchmail to start automatically in run levels 3 and 5 but only between the hours of 0700 and 1700 during weekdays. From my home account I can add a crontab entry: 0 7 * * * 1-5 sudo /sbin/rcfetchmail start 0 17 * * * 1-5 sudo /sbin/rcfetchmail stop
I would do that as root and not using sudo, as it is a system service which you want to run/stop. It should work, but I don't remember having tried. - -- Cheers, Carlos Robinson -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) Comment: Made with pgp4pine 1.76 iD8DBQFDwaeltTMYHG2NR9URAs9HAJ9LlrLb9ETNb2ZiGeg7QpHNCX1lgwCglkB4 74L+qtGj6o6Lm2V8u2kDRHI= =+f0z -----END PGP SIGNATURE-----
participants (2)
-
Carlos E. R.
-
Jerry Feldman