LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-26-2004, 10:37 AM   #1
Mugatu
Member
 
Registered: Dec 2003
Location: VA
Distribution: Ubuntu
Posts: 193

Rep: Reputation: 30
problems using cron


i have some unresolved network problems:

http://www.linuxquestions.org/questi...hreadid=145436

where my network stalls out and the only way to fix it is to restart my nic. so i created a script in my /root directory called netrestart which contains:

Code:
ifconfig eth0 down
ifconfig eth0 up
dhcpcd
and then i ran crontab -e and added this line:

Code:
0 0,6,12,18 * * * /bin/bash /root/netrestart 1> /dev/null
i made the netrestart script executable, and if i type ./netrestart it seems to work fine, but my cron job isn't executing. what did i skrew up? do i need to add #!/bin/bash or whatever to the top of my script? i figured i didn't cause it works fine when i run it. what about the fact that i ran crontab as root? i can't run this script as a user cause i won't be able to run ifconfig. root doesn't need to be logged in for root's cron jobs to run does it?
 
Old 02-26-2004, 11:58 AM   #2
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Blue Ridge Mountain
Distribution: Debian Jessie, Linux Mint 17
Posts: 7,793

Rep: Reputation: 292Reputation: 292Reputation: 292
"0 0,6,12,18 * * * /bin/bash /root/netrestart 1> /dev/null"

I think that you have specified to run your command on every December 6 when December 6 happens to be the eighteenth day of the week. The fields are:
minute hour day month dayofweek command

Here is a crontab man page:
http://campuscgi.princeton.edu/man?crontab

___________________________________
Be prepared. Create a LifeBoat CD.
http://users.rcn.com/srstites/LifeBo...home.page.html

Steve Stites
 
Old 02-26-2004, 12:21 PM   #3
Mugatu
Member
 
Registered: Dec 2003
Location: VA
Distribution: Ubuntu
Posts: 193

Original Poster
Rep: Reputation: 30
Quote:
Originally posted by jailbait
"0 0,6,12,18 * * * /bin/bash /root/netrestart 1> /dev/null"

I think that you have specified to run your command on every December 6 when December 6 happens to be the eighteenth day of the week. The fields are:
minute hour day month dayofweek command
if the first argument stands for minutes, then this should run at the beginning of the specified hours. if the second argument represents hours, then should this not run at 12am, 6am, 12pm, and 6pm? and then it should run every day, every month, every day of the week. i'm still learning and as always i'm open to suggestions, but honestly i'm not sure what i skrewed up. maybe i'm just misunderstanding it entirely...
 
Old 02-26-2004, 03:15 PM   #4
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Blue Ridge Mountain
Distribution: Debian Jessie, Linux Mint 17
Posts: 7,793

Rep: Reputation: 292Reputation: 292Reputation: 292
" should this not run at 12am, 6am, 12pm, and 6pm? and then it should run every day, every month, every day of the week."

Yes. You are correct. I gave you an incorrect answer off the top of my head where I assumed that the commas would be treated as white spaces. Sorry. Now I have checked your cron entry against a reference book, "Running Linux". Everything checks out OK.

In my crontab (set up by Fedora) there is a SHELL=/bin/bash variable set at the beginning and my crontab entries do not have a shell specified. So maybe you are specifying /bin/bash twice. You could try:
0 0,6,12,18 * * * /root/netrestart 1> /dev/null

It is also possible that Mandrake is using a variation of the cron system called the Vixie cron system. Fedora and Red Hat use the Vixie variation of cron and Mandrake patterns itself after Red Hat. You can tell that you are using Vixie if you have a script installed called /usr/bin/run-parts. If so, then your crontab entry should be:
0 0,6,12,18 * * * root run-parts /root/netrestart 1> /dev/null

___________________________________
Be prepared. Create a LifeBoat CD.
http://users.rcn.com/srstites/LifeBo...home.page.html

Steve Stites

Last edited by jailbait; 02-26-2004 at 03:16 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
cron problems deadite66 Linux - General 0 08-06-2005 07:29 PM
Cron Problems DNAphil Linux - Newbie 1 07-12-2005 08:56 AM
cron problems tassinari Linux - Newbie 8 04-02-2005 11:11 PM
CRON problems jlinden Linux - General 1 09-02-2003 03:16 PM
Cron problems goochable Linux - Newbie 3 04-17-2001 08:43 AM


All times are GMT -5. The time now is 04:28 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration