LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   bash script works when interactive, endless loop when started via cron (https://www.linuxquestions.org/questions/linux-general-1/bash-script-works-when-interactive-endless-loop-when-started-via-cron-429259/)

dguy 03-28-2006 08:39 AM

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.

nguyennh 03-28-2006 09:04 AM

What is your cron command to run your script ? Perhaps the time arguments cause your problem : they conflict with 30m on your script .

dguy 03-28-2006 09:14 AM

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.

dguy 04-01-2006 07:05 AM

Still looking for ideas...

gilead 04-01-2006 01:53 PM

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'.

dguy 04-10-2006 11:39 AM

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. :(


All times are GMT -5. The time now is 06:46 PM.