LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Problems with cron (https://www.linuxquestions.org/questions/linux-newbie-8/problems-with-cron-526353/)

Armethous 02-07-2007 06:19 AM

Problems with cron
 
I am running SUSE 10 on my linux box at home, and recently I have added a second NIC so that I can use it as a router. I now I want to disable eth1 at midnight and reenable it at 8am. I am trying to use cron to do this, so I logged in as root and used the crontab -e to add the following:

# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.XXXX37iRWq installed on Wed Feb 7 06:48:39 2007)
# (Cron version V5.0 -- $Id: crontab.c,v 1.12 2004/01/23 18:56:42 vixie Exp $)
50 2 * * 0-5 cat /root/messages/warning.txt | smbclient -M VESPER
00 0 * * 0-5 ifdown eth1
00 8 * * 0-5 ifup eth1

I have tested this several times and it does not appear to work. I at this point I am at a loss. Can someone point me in the right direction?

colucix 02-07-2007 07:28 AM

First you can check the standard error from cron jobs, which is sent to system mail by default. If you have edited crontab as root, type simply mail at the command line and see if any message has been sent from crond. Another hint is to put the full path of the commands in the crontab, since crontab itself has a very limited PATH by default, e.g.
Code:

00 8 * * 0-5 /sbin/ifup eth1
You can also test the crontab with a very simple command like
Code:

date > /root/cron.log
Also check if the cron daemon is running, e.g.
Code:

ps -u root | grep crond

Armethous 02-07-2007 12:34 PM

Thanks for the help
 
I put the complete path to ifup and ifdown into my crontab and that took care of the problem. Thanks for your help.

wpn146 02-07-2007 04:40 PM

Quote:

Originally Posted by Armethous
I put the complete path to ifup and ifdown into my crontab and that took care of the problem. Thanks for your help.

Another way would have been to set up your $PATH variable near the top of crontab. See
Code:

man 5 crontab
.


All times are GMT -5. The time now is 03:14 AM.