LinuxQuestions.org
Register a domain and help support LQ
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 04-13-2008, 10:58 AM   #1
Stefan J
Member
 
Registered: Oct 2006
Location: Leicestershire, England
Distribution: Ubuntu 7.04
Posts: 45

Rep: Reputation: 16
Problem starting a program from a script via crontab


Hi all

I am running a Mythtv frontend, if mythfrontend crashes I want to restart it automatically. I have the following script which works when run from the command line './mythfrontend_restart.sh'. However when I add the line to my crontab * * * * * /home/mythuser/mythfrontend_restart.sh nothing happerns. I know the script is getting ran as I have fed the output into a text file, it seems to ignore the 'mythfrontend' command.

#!/bin/bash

pidno=$( ps ax | grep mythfrontend.real | grep -v grep | grep -v mythmon)
# echo $pidno
# Checks for pid in "ps" listing, field #1.
# Then makes sure it is the actual process, not the process invoked by this scr$
# The last "grep $1" filters out this possibility.
if [ -z "$pidno" ] # If, after all the filtering, the result is a zero-length $
then # no running process corresponds to the pid given.
echo "No such process running."
mythfrontend
exit $E_NOSUCHPROCESS
fi

Any help gratefully received.

Regards

Stefan
 
Old 04-13-2008, 12:12 PM   #2
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,458

Rep: Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941
Try to give the full path to the command mythfrontend, since crontab has a very limited path (usually /bin and /usr/bin).
 
Old 04-13-2008, 01:25 PM   #3
Stefan J
Member
 
Registered: Oct 2006
Location: Leicestershire, England
Distribution: Ubuntu 7.04
Posts: 45

Original Poster
Rep: Reputation: 16
Tried that after making the post - same result.
 
Old 04-13-2008, 02:42 PM   #4
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,458

Rep: Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941
You've redirected output to a file and you've seen the message "No such process running"? Have you redirected the standard error as well?
 
Old 04-14-2008, 02:59 AM   #5
Stefan J
Member
 
Registered: Oct 2006
Location: Leicestershire, England
Distribution: Ubuntu 7.04
Posts: 45

Original Poster
Rep: Reputation: 16
How would i do that?
 
  


Reply

Tags
crontab, mythtv


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
Program initiated via python's os.system() doesn't work (when in crontab script) itmi Programming 3 03-03-2008 05:36 PM
Script having problem with Crontab DriveMeCrazy Programming 5 07-18-2005 03:29 PM
Starting a program from a shell script Suinatsa Programming 2 04-17-2005 12:16 AM
Bash backup script - If multiple files starting with a exist problem demoncheese Programming 2 07-29-2004 10:47 PM
Shell script running via crontab problem. thetruethugg Linux - Software 13 12-19-2003 08:56 PM


All times are GMT -5. The time now is 09:19 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