Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to add a crontab job in Debian Linux

Status
Not open for further replies.
Jun 5, 2008
4
AW
We are running CensorNet on a Debian Linux server.

This program is using two important daemons namely the squid daemon "/usr/local/squid/sbin/squid"
and dansguardian daemon "/usr/local/sbin/dansguardian".

Because these daemons tend to stop from time to time I need to configure the daemons to start every hour or so.

I need to edit the /etc/crontab file.

I am not sure if I need to put the "restart" command after the daemon.

If I am correct the crontab should look like something this:

min hr dmon mon wday user command
0 * * * * root /usr/local/squid/sbin/squid
0 * * * * root /usr/local/sbin/dansguardian


Do I have to put the "restart" (or "start" ) command after the daemon? Or can I leave it like this?
 
If they're running as deamons, you may wish to use...

0 * * * * /etc/init.d/squid restart
0 * * * * /etc/init.d/dansguardian restart

Check in the /etc/init.d folder, otherwise, I don't think you need the "root" parameter, just edit the cron as root. That should work.

Your logic for the time is right, it will run the program at 0 minutes every hour.

Mark
 
If they're in /etc/crontab, you do need to specify the user because that crontab file applies to any user.

If it's in root's own crontab (/var/spool/cron/root or something like that), i.e. the one you edit via crontab -e, then no username is required.

Annihilannic.
 
You are correct, I mistakingly overlooked the pointer to the file as listed and suggested the use root's cron only.

Mark
 
Kozusnik,

Thank you for your fast reply.

I did find the /etc/init.d/squid and /etc/init.d/dansguardian
services.

I logged in as root and used "crontab -e" to edit the crontab.
I typed :
0 * * * * /etc/init.d/squid restart
0 * * * * /etc/init.d/dansguardian restart

Is that OK or should I add the "root" between the last * and /etc/?

Let me know.

Lothar
 
If you were logged in as root, then those jobs will run as root. That should do it.

Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top