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.
Per our forum rules, all threads must have a descriptive subject text. For example, do not post questions with subjects like "Help Me!", "Urgent!!" or "Doubt". Post subjects like "Execution Problems with Cron" or "Help with Backup Shell Script".
The reason for this is that nearly 95% of all visitors to this site come here because they are referred by a search engine. In order for future searches on your post (with answers) to work well, the subject field must be something useful and related to the problem!
In addition, current forum users who are kind enough to answer questions should be able to understand the essence of your query at first glance.
So, as a benefit and courtesy to current and future knowledge seekers, please be careful with your subject text. You might receive a forum infraction if you don't pay attention to this.
Its working .Thank you very much for ur valuable reply.
Regards,
Vijay
---------- Post updated at 08:07 AM ---------- Previous update was at 08:05 AM ----------
Quote:
Originally Posted by johnbach
Hi,
Slight modification in my requirement, I want in the code that if the process is killed or aborted when the process is running, It should restart at that time also.
The signals are as below:
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;
}
I dont know how to trap these signals in the script.
Please let me solve in this issue.
To keep the forums high quality for all users, please take the time to format your posts correctly.
First of all, use Code Tags when you post any code or data samples so others can easily read your code. You can easily do this by highlighting your code and then clicking on the # in the editing menu. (You can also type code tags [code] and [/code] by hand.)
Second, avoid adding color or different fonts and font size to your posts. Selective use of color to highlight a single word or phrase can be useful at times, but using color, in general, makes the forums harder to read, especially bright colors like red.
Third, be careful when you cut-and-paste, edit any odd characters and make sure all links are working property.
---------- Post updated 05-08-09 at 01:42 PM ---------- Previous update was 04-08-09 at 06:20 PM ----------
I got Infractions from this answer. I can't still understand why ?
If we give solution and thread maker not test it, why we give answer ?
Makers first answer was
"Slight modification in my requirement, I want in the code that if the process is killed or aborted when the process is running, It should restart at that time also."
1st solution do it. Later added signal list give more info - then the 1st solution is not anymore answer even it's better - it can handle subprocess in every case, but if you try to restart yourself, you can handle only some interrupts.
Location: Asia Pacific, Cyberspace, in the Dark Dystopia
Posts: 19,118
Thanks Given: 2,351
Thanked 3,359 Times in 1,878 Posts
Quote:
Originally Posted by kshji
[/COLOR]I got Infractions from this answer. I can't still understand why ?
If we give solution and thread maker not test it, why we give answer ?
If you want others to follow rules, then you should follow rules yourself, right?
First of all, the forum rules are clear on the requirement to post descriptive subject text.
Your original subject text was clearly a rule violation, but our moderators did not give you an infraction for that. They were kind to you.
Then, you are unhappy when someone offers an untested suggestion. Why? Are you paying for the service here? What gives you any right to demand answers from others here in the way you want?
Perhaps English is not your native language. That is OK. However, the rules apply to all, regardless of language.
I hope my reply is clear.
You are welcome to post here, but you should follow the rules. Thanks.
Hi All,
I have a small queries to get the character count
i tried with wc -c and wc -m but its not returend current result
For eg:
wc -c
wc -m
echo "Name" | wc -c
result: 5 but actually it should returned 4
Help me on this to ge the correct one.
Thanks!
----------... (4 Replies)
Hi,
when i am trying below script
assume that below values are taken in code
#!/bin/ksh
if
then
echo usage: aNlist.sh QMGR NAME MQREQ
fi
NL=`echo 'dis qmgr'|runmqsc $1|grep REPOSNL|sed 's/.*REPOSNL\(.*\).*/\1/' |cut -d'(' -f2|cut -d')' -f1`
echo 'define nl('$NL_$2')... (25 Replies)
Hi All,
I am using the below script which has awk command, but it is not returing the expected result. can some pls help me to correct the command.
The below script sample.ksh should give the result if the value of last 4 digits in the variable NM matches with the variable value DAT. The... (7 Replies)
Hello everyone, I'm in need of some assistance. I'm currently enrolled in an introductory UNIX shell programming course and, well halfway through the semester, we are receiving our first actual assignment. I've somewhat realized now that I've fallen behind, and I'm working to get caught up, but for... (1 Reply)
I want to copy large amount of files aproximately more than 20,000 files from one file system to another file system, but it gives me error like:
#cd /opt/appserver/images
#cp * /opt/appserver02/public/images
Argument list is too long
Also above mention error appear again when i run:
... (1 Reply)
hi ,
I have a Solaris server which is part of a domain. The IP for this Solaris box is allocated dyanamically by a DHCP. Everytime the solaris box is restarted the IP gets changed. Being an admin what should i do to find the new ip of the Solaris server sitting at my location? Till now i get... (2 Replies)
In LINUX(CentOS, RedHat) is there a way to have the banner statement appear before the logon instead of after the logon? In UNIX and Windows the banner appears before a person actually logs on, what I'm seeing in LINUX is that it appears after the login(ftp, telnet, SSH).
Thanks (0 Replies)
Hi,
I have a shell scripting. This will take 7 digit number in each line and add 7 digit number with next subsequent lines ( normal addition ).
Eg:
0000001
0000220
0001235
0000022
0000023
...........
.........
........
Like this i am having around 1500000 records. After adding... (23 Replies)
HI All,
Suddenly don't know what happened to redhat linux 7.2 any program start then itsn't listing while using ps -ef
ex: ./xyz this xyz program pid not showing in ps-ef
Pls let me know what is the reason for the same.
Thanks a lot in advance
Bache (7 Replies)