06-23-2011
Finally got it with your help neutronscott. Thank you for all of your help.
I removed the " & echo $! > cb.pid" from the bottom of the chkscr script and added "ps -aef | grep -v grep | grep '/bin/bash /home/*user*/*serverdir*/exec' | awk '{print $2}' > cb.pid" to the next line.
Now it runs perfectly.
---------- Post updated at 04:38 PM ---------- Previous update was at 03:25 PM ----------
It's not working correctly. Spoke too soon, because my test didn't run long enough. It keeps making chkscr and exec processes. The check in the chkscr script is invalid.
I'm now looking for a check that checks the value in the file cb.pid to the actual PID of the process.
I can get the actual value of the processes PID by using "CBPID=$(ps -aef | grep -v grep | grep '/bin/bash /home/*user*/*serverdir*/exec' | awk '{print $2}')".
I can't find how to extract the PID number stored in the cb.pid file and make a valid "if actual PID = file's PID then end" statement.
Any help would be greatly appreciated.
Last edited by MacG32; 06-23-2011 at 05:56 PM..
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
hi all
How can I make a program start up automatically after the computer restart/startup in fedora?
something like:
... Establish a shell then run some of command code.
Thanks for Help!! (1 Reply)
Discussion started by: munna_dude
1 Replies
2. Shell Programming and Scripting
I need a shell script to kill apache and restart it, in case the number of processes keeps growing. The logic is like the below, but I don't know how to get the number and neither the syntax. Could somebody kindly help?
if no_of_processes (ps ax ¦ grep httpd) > 200
then
killall httpd... (14 Replies)
Discussion started by: _joshua_
14 Replies
3. AIX
Hi,
Very new to aix
How to start/stop/restart NFS on AIX
thanks, (2 Replies)
Discussion started by: jredx
2 Replies
4. UNIX for Advanced & Expert Users
How can I tell my syslog.conf to log "syslog start/stop/restart" messages on a Solaris box? (1 Reply)
Discussion started by: SunnyK
1 Replies
5. Shell Programming and Scripting
I'm wondering how I should make a script that can start, stop, and restart another script.
What I need to be able to do, is start and stop a perl script from the command line. The easiest way of doing this seems to be to have another script, starting and stopping the other script. I have BASH,... (7 Replies)
Discussion started by: Bakes
7 Replies
6. Shell Programming and Scripting
Hi All,
is there a way or script that i can check my AIX 5.3 OS will restart before i made restart? is there a script that can check all the startup files are ok before restarting. it is because i was stuck last time when i restart my PC because some startup files were missing:o. (2 Replies)
Discussion started by: malcomex999
2 Replies
7. Solaris
Please anyone tell me
In my last interview the HR asks me how to monitor, start,stop & kill the various processes and subprocesses.
Please anyone explain me clearly. It's my personal request (3 Replies)
Discussion started by: suneelieg
3 Replies
8. UNIX for Dummies Questions & Answers
Is there any functional difference between:
issuing separate stop/start commands like this;
super (handler) (instance) stop
super (handler) (instance) start
versus issuing a single recycle command like this;
super (handler) (instance) restart (3 Replies)
Discussion started by: Newbix
3 Replies
9. Emergency UNIX and Linux Support
Hi all
I have networker running on a RHEL 5.7 and over time it hangs. So the solution backup team proposed is to check if the process is hung, to stop and start it.
Unfortunately for me, the rc script only allows three commands, start, stop and status (no restart option) so I managed to set... (15 Replies)
Discussion started by: hedkandi
15 Replies
10. Red Hat
Hello,
I'l like to create a script that restart a service (/etc/init.d/httpd restart) and also check if after restart the service is actually running. Sometimes it happen that at the first try the service fails to restart.
Thanks (2 Replies)
Discussion started by: bazzola
2 Replies
LEARN ABOUT CENTOS
nsenter
NSENTER(1) User Commands NSENTER(1)
NAME
nsenter - run program with namespaces of other processes
SYNOPSIS
nsenter [options] [program] [arguments]
DESCRIPTION
Enters the namespaces of one or more other processes and then executes the specified program. Enterable namespaces are:
mount namespace
mounting and unmounting filesystems will not affect rest of the system (CLONE_NEWNS flag), except for filesystems which are explic-
itly marked as shared (by mount --make-shared). See /proc/self/mountinfo for the shared flag.
UTS namespace
setting hostname, domainname will not affect rest of the system (CLONE_NEWUTS flag).
IPC namespace
process will have independent namespace for System V message queues, semaphore sets and shared memory segments (CLONE_NEWIPC flag).
network namespace
process will have independent IPv4 and IPv6 stacks, IP routing tables, firewall rules, the /proc/net and /sys/class/net directory
trees, sockets etc. (CLONE_NEWNET flag).
PID namespace
children will have a set of PID to process mappings separate from the nsenter process (CLONE_NEWPID flag). nsenter will fork by
default if changing the PID namespace, so that the new program and its children share the same PID namespace and are visible to each
other. If --no-fork is used, the new program will be exec'ed without forking.
See the clone(2) for exact semantics of the flags.
If program is not given, run ``${SHELL}'' (default: /bin/sh).
OPTIONS
Argument with square brakets, such as [file], means optional argument. Command line syntax to specify optional argument --mount=/path/to
/file. Please notice the equals sign.
-t, --target pid
Specify a target process to get contexts from. The paths to the contexts specified by pid are:
/proc/pid/ns/mnt the mount namespace
/proc/pid/ns/uts the UTS namespace
/proc/pid/ns/ipc the IPC namespace
/proc/pid/ns/net the network namespace
/proc/pid/ns/pid the PID namespace
/proc/pid/root the root directory
/proc/pid/cwd the working directory respectively
-m, --mount [file]
Enter the mount namespace. If no file is specified enter the mount namespace of the target process. If file is specified enter the
mount namespace specified by file.
-u, --uts [file]
Enter the UTS namespace. If no file is specified enter the UTS namespace of the target process. If file is specified enter the UTS
namespace specified by file.
-i, --ipc [file]
Enter the IPC namespace. If no file is specified enter the IPC namespace of the target process. If file is specified enter the IPC
namespace specified by file.
-n, --net [file]
Enter the network namespace. If no file is specified enter the network namespace of the target process. If file is specified enter
the network namespace specified by file.
-p, --pid [file]
Enter the PID namespace. If no file is specified enter the PID namespace of the target process. If file is specified enter the PID
namespace specified by file.
-r, --root [directory]
Set the root directory. If no directory is specified set the root directory to the root directory of the target process. If direc-
tory is specified set the root directory to the specified directory.
-w, --wd [directory]
Set the working directory. If no directory is specified set the working directory to the working directory of the target process.
If directory is specified set the working directory to the specified directory.
-F, --no-fork
Do not fork before exec'ing the specified program. By default when entering a pid namespace enter calls fork before calling exec so
that the children will be in the newly entered pid namespace.
-V, --version
Display version information and exit.
-h, --help
Print a help message.
SEE ALSO
setns(2), clone(2)
AUTHOR
Eric Biederman <ebiederm@xmission.com>
AVAILABILITY
The nsenter command is part of the util-linux package and is available from Linux Kernel Archive <ftp://ftp.kernel.org/pub/linux/utils
/util-linux/>.
util-linux January 2013 NSENTER(1)