location of logginexpert.sh is /tmp/logginexpert.sh
ps -ef | pgrep /tmp/testbkpme.sh
No results Found.
ps -ef | pgrep bk
No results Found.
ps -ef also does not show /tmp/logginexpert.sh but I'm able to grep the process by the pid but not with the script name.
Putty Session 1:
/tmp/logginexpert.sh &
[1] 4627
Putty Session 2:
You have new mail in /var/mail/user2
ps -ef | grep 4627
user1 4627 10477 0 13:54:09 pts/11 0:00 sleep 888
ps -ef | grep ex
user2 5650 15730 0 13:54:27 pts/16 No results Found.
So definitely the process is running.
---------- Post updated at 03:12 PM ---------- Previous update was at 02:36 PM ----------
Also ps -ef does not show the name of the script but i see this sleep 888 in the results.
Can you please help sort this out ? i want to grep by name of the script not by its contents.
The issue is not to do with different users or different putty session. Becoz i Cannot find i.e grep for the logginexpert.sh script with the same user in the same putty session.
Also,
/bin/ps -fu | /bin/grep ex
/bin/ps: option requires an argument � u
pgrep -u user1 ex
No results Found.
/bin/ps fu | /bin/grep ex
/bin/ps: illegal option -- f
/bin/ps u | /bin/grep bk
Result not Found.
The script name is logginexpert.sh which has the sleep 888 line in it.
So, when i run logginexpert.sh in the background i see the sleep 888 which is shown in the output of my /bin/ps -ef command.
So, it is not listing the process with the name of the script i.e logginexpert.sh which is what i want !! ...instead it is listing the sleep 888 command that is in the script.
And I'd challenge that statement. A script would usually wait for its children (and then show up in the ps listing). I don't even believe you put sleep 888 into background with nohup or disown , as then, it's parent would become 1 ( init ).
Post the relevant part of logginexpert.sh .
Well, that depends on what the overall process is. What are you trying to work out?
For instance:-
Are you trying to ensure you only have one copy of a script running at a time?
Do you have different scripts that must not run together?
Are you trying to raise alerts with script overrunning?
if we can understand the context, then we may be able to suggest a better solution that will be flexible and let you evolve and support the code for the future.
Seems to be a SysV thing. I reproduced this behavior on HP-UX and AIX.
If there is no shebang, the execve() does not change the args, so they remain from the previous fork() i.e. are a copy from the invoking shell.