Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: how to make a run a orogram as sooon as linux is being started

by mwah (Hermit)
on May 24, 2008 at 13:56 UTC ( #688296=note: print w/replies, xml ) Need Help??


in reply to how to run your program when the system is started....

(Not exactly a Perl question, but often puzzles unix/linux newbies.)

Two things here. The first one:

how to make a program run as soon as linux is being started

... is usually beeing accomplished by putting the program invocation into the appropriate startup file, most probably (you mentioned "Linux" which one?) the file etc/init.d/boot.local, like mine:

$> cat /etc/init.d/boot.local

starts the cpu temperature sensors package:

#! /bin/sh modprobe w83627hf sleep 1 # optional /usr/bin/sensors -s

the other question was:

how to make my program run atomatically as as soon as somebody log into the linux system

Same thing here, put the command into the appropriate file, for bash login shell, this might be the file ~/.bashrc in your home directory.

For example, you have a program called 'anonymoushydrogen.pl' in your home directory, which contains the following code:

#!/usr/bin/perl print "Hello anonymoushydrogen!\n";

then, you may put the command:

perl ~/anonymoushydrogen.pl

into your .bashrc and all is fine.

But: the exact name of the file may depend on your shell or login configuration (.bashrc, .profile, .bash_profile etc.).

Regards

mwa

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://688296]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2021-04-11 00:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?