> it is a news application which we start using the command "ant all" in
> unix as root.
> but what i really want to do is to check whether the application is
> already running and if not start it automatically....i think it
> involves a crontab entry..also i want to start it automatically at
> boot.
you should try with rc.d scripts, which will be proably located in /etc/rc.d
create file called rc.ant, looking more or less like this:
#!/bin/sh
case "$1" in
'start')
if [ -f /var/run/ant.pid ]; then
echo ant is already running
exit 1
else
echo Starting ant: /usr/bin/ant all
/usr/bin/ant all
pidof ant > /var/run/ant.pid
fi ;;
'stop')
if [ -f /var/run/ant.pid ]; then
ANT_PID="`cat /var/run/ant.pid`"
kill -TERM "$ANT_PID"
rm /var/run/ant.pid
else
echo ant is not running
exit 1
fi ;;
'restart')
if [ -f /var/run/ant.pid ]; then
ANT_PID="`cat /var/run/ant.pid`"
kill -HUP "$EXIM_PID"
else
$0 start
fi ;;
*)
echo "usage: $0 start|stop|restart" ;;
esac
above code is simplest skeleton, so may fail if something unexpected will happen.
you may extend it, or look at other scripts in /etc/rc.d/
when this script is ready, make it executable and add to other boot scripts.
depending on your unix version, you'll have to
a) add a line "/etc/rc.d/rc.ant start" to /etc/rc.d/rc.$RUNLEVEL (RUNLEVEL is 3, 4 or 5)
and line "/etc/rc.d/rc.ant stop" to /etc/rc.d/rc.0 and /etc/rc.d/rc.6
(it looks like that on my slackware linux, i don't remember exact pathes and filenames
in other OSes, but i hope, someone other will tell something more...)
remember, when you decide to use such scripts, always start your news application
through /etc/rc.d/rc.ant start and stop it by using /etc/rc.d/rc.ant stop
state of your process will be indicated by file /var/run/ant.pid - when it will be
running, file will store PID of application's process, when no, file will be unlinked.
--
Jacek Pospychala - tri10o at bsod dot org