LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 03-20-2006, 01:55 PM   #1
monty
LQ Newbie
 
Registered: Mar 2004
Location: Valdosta, GA
Distribution: Suse Pro 10.0
Posts: 10

Rep: Reputation: 0
using cron to start and stop a bash script


I'm trying to use cron to run a shell script at a specific time, then run another script to stop the initial script 3 and a half hours later. The script will start properly, and running the stop script manually stops the process, but it doesn't seem to run through cron and stop the process. here are the relevant files...

START.SH
Code:
#/bin/bash

TGTD="/home/apps/spec3130/"
OF=spec3130-$(date +%F).rm

#Production line for pushing video to a legacy push server and archiving the file.
/home/apps/producer/producer -pid /tmp/producer.pid -vc /dev/video0 -vp 01 -ac /dev/dsp -ap 06 -cs 640x480 -d 3:30:00 -o $TGTD$OF

wait
STOP.SH
Code:
#!/bin/sh

kill -s 2 $(cat /tmp/producer.pid)
CRONTAB
Code:
SHELL=/bin/sh
PATH=/usr/bin:/usr/sbin:/sbin:/bin:/usr/lib/news/bin
MAILTO=root
#
# check scripts in cron.hourly, cron.daily, cron.weekly, and cron.monthly
#
-*/15 * * * *   root  test -x /usr/lib/cron/run-crons && /usr/lib/cron/run-crons >/dev/null 2>&1
*/5   * * * *   cactiuser php /srv/www/htdocs/cacti/poller.php > /dev/null 2>&1
00   17 * * Thu   root /home/apps/start.sh
30   20 * * Thu   root /home/apps/stop.sh
I'm a relative newb at shell scripting. any suggestions?
 
Old 03-20-2006, 02:06 PM   #2
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,141

Rep: Reputation: 168Reputation: 168
If you have a crond environment where those commands aren't in the path, try using the full path to the command. On my system, stop.sh would be:
Code:
#!/bin/sh

/bin/kill -s 2 $(/usr/bin/cat /tmp/producer.pid)
 
Old 03-20-2006, 02:30 PM   #3
monty
LQ Newbie
 
Registered: Mar 2004
Location: Valdosta, GA
Distribution: Suse Pro 10.0
Posts: 10

Original Poster
Rep: Reputation: 0
still a no go. I do a ps ax after the stop.sh script is supposed to have run and the start script is still up and running along with the producer process it starts...
 
  


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
bash script & cron probs. skubik Programming 17 10-16-2005 02:00 PM
cron bash script troubles zzyzx Slackware 3 04-12-2005 12:27 PM
bash script to stop isdn service after x mintus? paul.nel Programming 4 03-11-2004 10:01 AM
bash script from cron kubla Programming 3 01-22-2004 04:30 AM
webmin,cron and bash login script colesen Linux - Software 0 08-12-2003 07:36 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:54 PM.

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