LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   using cron to start and stop a bash script (https://www.linuxquestions.org/questions/linux-software-2/using-cron-to-start-and-stop-a-bash-script-426674/)

monty 03-20-2006 01:55 PM

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?

gilead 03-20-2006 02:06 PM

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)


monty 03-20-2006 02:30 PM

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


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