LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-28-2009, 12:37 PM   #1
mwkemo
Member
 
Registered: May 2009
Location: Croatia
Distribution: Debian
Posts: 31

Rep: Reputation: 16
crontab help


Hello, having problem with crontab. If I run script from shell the script is working, but if the script is run from crontab, the script doesn't execude corectly.

Code:
#!/bin/bash

dsl0=`/sbin/ifconfig -a | grep "dsl0"`
if [ -n "$dsl0" ];then
echo "dsl0 is up"
echo "`date` DSL IS UP" >> /var/log/messages
else
echo "dsl0 IS DOWN"
echo "`date` DSL IS DOWN" >> /var/log/messages
ifup dsl0
fi
This checks if dsl0 interface is UP, if it's down then the script brings it UP. In /var/log/messages i can see that there is echo "`date` DSL IS DOWN" but id doesn't bring the dsl0 interface UP. So the script is execudet from crontab but it doesn't bring the interface UP.

This is my crontab with root account:

*/15 * * * * /bin/checkdsl

I'm using OpenSuse 11.1 if this make any difference.

Last edited by mwkemo; 10-28-2009 at 12:38 PM.
 
Old 10-28-2009, 12:40 PM   #2
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,529

Rep: Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899
Since cron has limited path, use the whole path to the commands
eq

Quote:
/sbin/ifup
 
Old 10-28-2009, 12:52 PM   #3
mwkemo
Member
 
Registered: May 2009
Location: Croatia
Distribution: Debian
Posts: 31

Original Poster
Rep: Reputation: 16
Heh, I thought it was something idiotic:-). Thanks
 
Old 10-28-2009, 01:11 PM   #4
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by repo View Post
Since cron has limited path, use the whole path to the commands
eq
Or set the PATH-u-like in the script
 
  


Reply



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
linux crontab vs unix crontab ytd Linux - General 2 08-09-2009 05:07 AM
replaced crontab, now should get crontab back to what it was raminn Linux - Newbie 2 10-20-2008 07:15 PM
man crontab(5) vs crontab(1) Canis Polaris Linux - Newbie 2 06-04-2008 04:03 PM
system-wide crontab in /etc/crontab ner Linux - General 2 11-18-2003 12:35 PM
Crontab WiWa Linux - Software 1 10-06-2003 05:20 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:21 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
Open Source Consulting | Domain Registration