| | |
hi all please help me in this issue.
Please support our Shell Scripting advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Aug 2009
Posts: 4
Reputation:
Solved Threads: 0
Hi all,
I am very new to shell scripting.I have the requirement like
one program is there, if it is running leave like that only and if it is stopped it has to be restart and once again keep watching and it is stopped we a have to restart once agian.I want a shell script for this.Please help me in this.
This is an urgent one.Thanks in advance.
I am very new to shell scripting.I have the requirement like
one program is there, if it is running leave like that only and if it is stopped it has to be restart and once again keep watching and it is stopped we a have to restart once agian.I want a shell script for this.Please help me in this.
This is an urgent one.Thanks in advance.
What distribution or operating system are you referring to? In linux the init.d files do exactly this by writing out PID files to see if the program is still alive when it re-executes.
Please provide more information.
Please provide more information.
•
•
Join Date: Aug 2009
Posts: 4
Reputation:
Solved Threads: 0
•
•
•
•
What distribution or operating system are you referring to? In linux the init.d files do exactly this by writing out PID files to see if the program is still alive when it re-executes.
Please provide more information.
If i have a program.c and it is running.Different signals comes into picture.Like below
The program may be like
Shell Scripting Syntax (Toggle Plain Text)
#include <stdio.h> int main() { printf("Message 1\n"); sleep(10); }
The signals are,
Shell Scripting Syntax (Toggle Plain Text)
switch(signum){ case SIGHUP: return "JVM hangup"; break; case SIGINT: return "JVM interrupted"; break; case SIGQUIT: return "JVM Quit"; break; case SIGILL: return "Illegal instruction"; break; case SIGABRT: return "JVM aborted"; break; case SIGFPE: return "Floating point exception"; break; case SIGKILL: return "JVM killed"; break; case SIGBUS: return "Bus error"; break; case SIGSEGV: return "Segmentation violation"; break; case SIGSYS: return "Bad argument to system call"; break; case SIGTERM: return "Software termination signal from kill"; break; case SIGCHLD: return "Child process terminated or stopped"; break; default: return "JVM abnormally terminated"; break; }
This is what I required.But i dont know how to code these signlas to trap.
I think I am clear from my end.If you didnt get my requirement please let me know.
If you start a new instance of the program then it won't signal the existing version.
Here are some pid file examples:
http://candrews.integralblue.com/200...-file-in-bash/
http://www.franzone.com/2007/09/23/h...ready-running/
http://ubuntuforums.org/archive/index.php/t-530553.html
Here are some pid file examples:
http://candrews.integralblue.com/200...-file-in-bash/
http://www.franzone.com/2007/09/23/h...ready-running/
http://ubuntuforums.org/archive/index.php/t-530553.html
•
•
Join Date: Aug 2009
Posts: 4
Reputation:
Solved Threads: 0
i,
Thank you very much for your valuable reply.But i have some doubt.
what is pidfile.Where it is created.I am new to unix please clarify my doubt.
Thanks,
Vijay,
Thank you very much for your valuable reply.But i have some doubt.
what is pidfile.Where it is created.I am new to unix please clarify my doubt.
Shell Scripting Syntax (Toggle Plain Text)
#!/bin/bash pidfile=/var/run/sync.pid PROGRAM="/home/test/vijay/vijay1" $PROGRAM if [ -e $pidfile ]; then pid=`cat $pidfile` if kill -0 &>1 > /dev/null $pid; then echo "Already running" exit 1 else rm $pidfile fi fi echo $$ > $pidfile #do your thing here rm $pidfile
Thanks,
Vijay,
When you create a process it is assigned a 'process id' or PID. In the PID file you write out the process ID .. that way you can see if that process is still running so you dont start up a new instance every time. you can change the location of the pid file by changing the
pidfile= line ![]() |
Similar Threads
- Windows Explorer Issue: my "Address" bar is gone, how do I get it back? (Windows NT / 2000 / XP)
- Power boot up issue (Motherboards, CPUs and RAM)
- Getting Windows to see a SATA drive (Storage)
- BitchX + Terminal issue (Mac Software)
- Kernel Version of Mandrake and error message (*nix Software)
- Memory Issue's! Please Help!! (Motherboards, CPUs and RAM)
- Internet Explorer Connection Issue (Web Browsers)
- Netgear router issue...read this if you have one (Networking Hardware Configuration)
Other Threads in the Shell Scripting Forum
- Previous Thread: Need some help with compression / move script
- Next Thread: Trimming some string using shell script
Views: 570 | Replies: 6
| Thread Tools | Search this Thread |
Tag cloud for Shell Scripting






