Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 12-19-2003, 07:14 PM   #1
Registered: Jul 2003
Location: Ft Lauderdale, FL
Distribution: debian
Posts: 48

Rep: Reputation: 15
how to find the pid of a perl script from shell script

Thanks in advance to the responder

I run a perl script that "tail -f /var/log/syslog" looking for iptables enteries and puts them into the snort mysql db.

I run it from /etc/init.d as follows:
# Log Iptables Data to Snort Mysql Log For Acid Viewing

case "$1" in
echo "Starting Logsnorter"
logsnorter-0.2 -L 8 -T /var/log/syslog &
echo "Logsnorter Started"
echo "Usage: $0 { start | stop }"
exit 0

Everthing works fine until logrotate comes along and kills the script at about 6am

I need to know how to restart the perl script from cron - more specifically, how to find the pid of the script and kill it from inside a shell script. Anybody have an example shell script they could throuw up? Thanks

Brian Toovey
Old 12-19-2003, 07:25 PM   #2
Senior Member
Registered: Jul 2003
Location: Indiana
Distribution: Mandrake Slackware-current QNX4.25
Posts: 1,802

Rep: Reputation: 47
To kill it you might try

killall -15 $0
killall -9 $0

To find the pid try this.
pidof $0


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell Scripting: Getting a pid and killing it via a shell script topcat Programming 15 10-28-2007 03:14 AM
Getting PID from a system command in Linux perl script sumbabs Linux - General 1 03-03-2005 11:38 AM
reading idle time with perl/shell script daryl314 Linux - General 1 12-27-2004 02:11 PM
Shell Script, C, C++, or Perl ? mrpc_cambodia Programming 5 08-12-2004 11:18 AM
obtaining PID of shell script sanjith11 Programming 3 07-14-2004 11:43 AM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:00 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration