![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Perl: Extracting date from file name and comparing with current date | MKNENI | Shell Programming and Scripting | 4 | 03-26-2008 04:01 PM |
| what is the meaning of ppid 1? | darkrainbow | UNIX for Dummies Questions & Answers | 2 | 08-02-2007 10:56 AM |
| Need a script to kill processes with PPID of 1 | lbaysdon | Shell Programming and Scripting | 5 | 04-13-2005 01:01 PM |
| strange pid and ppid problem | asvija | UNIX for Advanced & Expert Users | 3 | 03-10-2005 11:34 PM |
| printing ppid,child pid,pid | a25khan | High Level Programming | 3 | 02-02-2004 01:13 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
All, I've got a script that needs to check if it was started by cron. The code seems to be right, but it's not running correctly if cron starts it. Am I getting the pid's correctly? I'm not having any luck figuring it out. Any help is appreciated!Code:
CRON_ID=$(ps -aef | grep /usr/sbin/cron | grep -v grep | awk '{print $2}')
CP_ID=$(ps -aef | grep $PPID | grep -v root | grep -v grep | awk '{print $3}')
if test $CRON_ID = $CP_ID
then
# cron started the script
else
# user started the script
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|