LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
LinkBack Search this Thread
Old 03-28-2006, 08:39 AM   #1
dguy
Member
 
Registered: Dec 2001
Location: Beckwith Township, Ontario, Canada
Distribution: Slackware 13.0
Posts: 110

Rep: Reputation: 16
bash script works when interactive, endless loop when started via cron


Hi,

I use the following within a homebrew backup script to loop until a tape has been loaded:

Code:
while [ `mt-st -f /dev/nst0 status | grep -c "ONLINE"` != 1 ]; do
  sleep 30m
done
Works like a charm when the script is run manually in a terminal. When started via cron however, the loop condition is never met. I can verify that the tape drive is online from an independent session, yet every 30 minutes a new instance of sleep is spawned instead of the script carrying on.

What am I missing?


-d.
 
Old 03-28-2006, 09:04 AM   #2
nguyennh
Member
 
Registered: Feb 2006
Location: Vietnam
Distribution: FC , RH , SuSE
Posts: 106

Rep: Reputation: 15
What is your cron command to run your script ? Perhaps the time arguments cause your problem : they conflict with 30m on your script .
 
Old 03-28-2006, 09:14 AM   #3
dguy
Member
 
Registered: Dec 2001
Location: Beckwith Township, Ontario, Canada
Distribution: Slackware 13.0
Posts: 110

Original Poster
Rep: Reputation: 16
cron is set to run the script once a week, by simply invoking the name of the script with a fully-qualified path, without any stdout/stderr redirection.
 
Old 04-01-2006, 07:05 AM   #4
dguy
Member
 
Registered: Dec 2001
Location: Beckwith Township, Ontario, Canada
Distribution: Slackware 13.0
Posts: 110

Original Poster
Rep: Reputation: 16
Still looking for ideas...
 
Old 04-01-2006, 01:53 PM   #5
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,123

Rep: Reputation: 151Reputation: 151
Have you tried it with the full paths to mt-st and grep? If your cron uses a different path to your shell account it may not find the commands and the code in the backticks will never return a '1'.
 
Old 04-10-2006, 11:39 AM   #6
dguy
Member
 
Registered: Dec 2001
Location: Beckwith Township, Ontario, Canada
Distribution: Slackware 13.0
Posts: 110

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by gilead
Have you tried it with the full paths to mt-st and grep?
Thanks for the suggestion!

Unfortunately however, using full path references didn't change a thing.
 
  


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 On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
bash script loop bong.mau Programming 6 09-14-2005 07:38 PM
how to implement an endless loop in a rc startup script garba Linux - General 6 05-03-2005 11:30 AM
bash script for loop drisay Programming 5 12-25-2004 12:32 AM
bash script - for loop question rignes Programming 3 10-05-2004 11:16 PM
HELP- endless loop contrasutra Linux - Software 2 04-26-2003 11:25 AM


All times are GMT -5. The time now is 08:51 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration