LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 12-19-2003, 06:14 PM   #1
toovato
Member
 
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:
#!/bin/sh
# Log Iptables Data to Snort Mysql Log For Acid Viewing

case "$1" in
'start')
echo "Starting Logsnorter"
logsnorter-0.2 -L 8 -T /var/log/syslog &
echo "Logsnorter Started"
;;
'stop')
;;
*)
echo "Usage: $0 { start | stop }"
;;
esac
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, 06:25 PM   #2
/bin/bash
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
or
killall -9 $0

To find the pid try this.
pidof $0
 
  


Reply



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 02:14 AM
Getting PID from a system command in Linux perl script sumbabs Linux - General 1 03-03-2005 10:38 AM
reading idle time with perl/shell script daryl314 Linux - General 1 12-27-2004 01:11 PM
Shell Script, C, C++, or Perl ? mrpc_cambodia Programming 5 08-12-2004 10:18 AM
obtaining PID of shell script sanjith11 Programming 3 07-14-2004 10:43 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:38 AM.

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