LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-20-2005, 04:36 PM   #1
andy7t
Member
 
Registered: Oct 2004
Posts: 43

Rep: Reputation: 15
Running Perl Script upon startup


I have a perl script that I need to run when my computer starts.
It must run as root.
I'm using Suse 9.1 Personal.
 
Old 04-20-2005, 05:43 PM   #2
peter72
Member
 
Registered: Oct 2002
Location: Charlottesville, VA
Distribution: Ubuntu (home), SLES (work)
Posts: 196
Blog Entries: 1

Rep: Reputation: 30
2 possible solutions that I can think of to do this.

1. Make it a service. Have to make a start up script (bourne shell usually) and link the script to whatever run level directory you want it to start at ( probable 5 ).
2. Add the perl script to the a similar init script ( ie. if it is a network thing, then add the /etc/init.d/network script ). This is cheating, and not really advisable, but definately the easiest method.

basic startup script follows:

#########################
# start some process
#########################

RETVAL=0
case "$1" in
start)
/yourpathtoscript/script.pl
;;
stop)
## pkill very dangerous, ensure the perl script name is unique
pkill script.pl
;;
status|restart|reload)
;;
*)
echo "Usage: sysstat {start|stop|status|restart|reload}"
exit 1
esac
exit $RETVAL
######
## end of script
######

make script executable and copy to /etc/init.d/

Then you need to decide the run_level ( probable 5 ) and do either symbolic link to /etc/rc5.d

# cd /etc/rc5.d
# ln -s ../init.d/yourstartscript S99yourstartscript

The S99 is order in which it is started. You can also ( and should ) make a K99yourstartscript, which will properly kill the process on reboots and changes to the run-level.

I probable forgot something, but this should get you started.

Pete
 
  


Reply


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Running a Perl script with SendMail NewByy Linux - Newbie 4 08-25-2005 02:02 PM
Running a Perl script with SendMail NewByy Programming 2 08-25-2005 10:56 AM
Running a perl script bobfinners Linux - Software 1 06-23-2005 06:18 PM
running perl script dav_y2k Linux - Newbie 3 04-25-2005 06:00 AM
Perl script not running on FreeBSD J_Szucs *BSD 12 07-13-2002 10:05 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:39 PM.

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