LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 08-04-2012, 06:56 PM   #1
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Rep: Reputation: 76
Place to put a certain script to be run at boot time.


Hi:

Where could I place the following script to make it execute each time I boot?:
Code:
#!/bin/bash
( sudo setsid /kbd_monitor /dev/input/event1 </dev/null &>/tmp/input.log & )
I want have it run system-wide. There are three choices that I know of:
(a) /etc/inittab
(b) /etc/profile
(c) /etc/rc.d/rc.local

I put it in profile with no effects. As to inittab I refrained from touching it. Perhaps rc.local?

Kernel 2.6.21.5
Slackware 12.0
 
Old 08-04-2012, 07:14 PM   #2
damgar
Senior Member
 
Registered: Sep 2009
Location: dallas, tx
Distribution: Slackware - current multilib/gsb Arch
Posts: 1,949
Blog Entries: 8

Rep: Reputation: 203Reputation: 203Reputation: 203
Quote:
I A /etc/rc.d/rc.local (sh) Row 1 Col 1 6:13 Ctrl-K H for help
#!/bin/sh
#
# /etc/rc.d/rc.local: Local system initialization script.
#
# Put any local startup commands in here. Also, if you have
# anything that needs to be run at shutdown time you can
# make an /etc/rc.d/rc.local_shutdown script and put those
# commands in there.
From rc.local
 
Old 08-04-2012, 07:17 PM   #3
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
my bet would be on rc.local.

i usually add an entry in crontab like so:
Code:
@reboot /run/this/script
 
1 members found this post helpful.
Old 08-04-2012, 07:31 PM   #4
willysr
Senior Member
 
Registered: Jul 2004
Location: Jogja, Indonesia
Distribution: Slackware-Current
Posts: 4,651

Rep: Reputation: 1772Reputation: 1772Reputation: 1772Reputation: 1772Reputation: 1772Reputation: 1772Reputation: 1772Reputation: 1772Reputation: 1772Reputation: 1772Reputation: 1772
it would be best to use absolute path instead of relative path if you are going to put it on your rc.local
 
2 members found this post helpful.
Old 08-04-2012, 08:11 PM   #5
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
rc.local was my first choice, and it did nothing. 'ps -C kbd_monitor', as it is in /usr/bin/, shows it isn't running.
 
Old 08-04-2012, 08:13 PM   #6
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
I did used the absolute path.
 
Old 08-04-2012, 08:42 PM   #7
damgar
Senior Member
 
Registered: Sep 2009
Location: dallas, tx
Distribution: Slackware - current multilib/gsb Arch
Posts: 1,949
Blog Entries: 8

Rep: Reputation: 203Reputation: 203Reputation: 203
Did you remember to
Code:
chmod +x /etc/rc.d/rc.local
And I believe he means absolute path for the command such as /usr/bin/setsid instead of just setsid
 
1 members found this post helpful.
Old 08-05-2012, 02:55 AM   #8
Mark Pettit
Member
 
Registered: Dec 2008
Location: Cape Town, South Africa
Distribution: Slackware 15.0
Posts: 617

Rep: Reputation: 297Reputation: 297Reputation: 297
You won't need the 'sudo' either, as rc.local will run as root on boot.
 
Old 08-05-2012, 03:13 AM   #9
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
Thanks, I did not use the sudo, of course. But now, having put the full pathname of setsid, it starts after boot. Cool!
 
Old 08-06-2012, 01:44 PM   #10
ottavio
Member
 
Registered: Nov 2007
Posts: 312

Rep: Reputation: 46
Quote:
Originally Posted by schneidz View Post
my bet would be on rc.local.

i usually add an entry in crontab like so:
Code:
@reboot /run/this/script
Isn't this deprecated? Or at least I thought all 'at' crontabs were.
 
Old 08-06-2012, 01:46 PM   #11
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
i never heard that but i think putting it in rc.local is more leet.
 
Old 08-06-2012, 02:08 PM   #12
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
A little off-topic but there it goes: what should I do if I want a message written by me output to stdout just after boot to remind me a certain thing? I have tried several places but i'm defeated by the famous slack daily quotation! If it fills the screen then my message cant be read at first sight and anyways, I want it to be the very last thing printed.
 
Old 08-06-2012, 05:39 PM   #13
T3slider
Senior Member
 
Registered: Jul 2007
Distribution: Slackware64-14.1
Posts: 2,367

Rep: Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843
Quote:
Originally Posted by stf92 View Post
A little off-topic but there it goes: what should I do if I want a message written by me output to stdout just after boot to remind me a certain thing? I have tried several places but i'm defeated by the famous slack daily quotation! If it fills the screen then my message cant be read at first sight and anyways, I want it to be the very last thing printed.
To stop fortunes from being displayed on login you can remove the executable bit on /etc/profile.d/bsd-games-login-fortune.sh (and/or /etc/profile.d/bsd-games-login-fortune.csh depending on the shell(s) you use) and it will not be run.
Code:
chmod -x /etc/profile.d/bsd-games-login-fortune.*
To display a custom message you can either add a script to /etc/profile.d/ that gets run each time you login, create a .bash_profile (or similar file for whatever shell you use) in your user's home directory that gets run whenever your specific user logs in, or edit /etc/motd to add a system-wide message (not a script) that gets displayed upon login in a login shell. Note that the motd file is modified on system boot to show the proper kernel version but only if the file's structure is correct. It should ideally look like this:
Code:
Linux 2.6.37.6
Other stuff written here...
where the version number is the kernel version number (this first line gets overwritten by rc.S).
 
1 members found this post helpful.
Old 08-06-2012, 06:39 PM   #14
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
So all executable files in /etc/profile.d get executed when an interactive login shell runs. But none of them writes stdout as I see, save for bsd-games-login-fortune.sh. Now if I want to retain this together with my message, which script will be run first (mine or bsd-games-login-fortune.sh)? Thanks for an illustrative post.
 
Old 08-06-2012, 08:21 PM   #15
T3slider
Senior Member
 
Registered: Jul 2007
Distribution: Slackware64-14.1
Posts: 2,367

Rep: Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843
Quote:
Originally Posted by stf92 View Post
Now if I want to retain this together with my message, which script will be run first (mine or bsd-games-login-fortune.sh)? Thanks for an illustrative post.
From /etc/profile:
Code:
for profile_script in /etc/profile.d/*.sh ; do
  if [ -x $profile_script ]; then
    . $profile_script
  fi
done
I believe bash expands file listings in alphabetical order, so if you want fortune to run but you want your script to run later, you should workaround this by naming it "zzz_scriptname.sh" or something similar. Obviously a little hacky but short of renaming all files in /etc/profile.d/ to contain numbered prefixes I can't see another way around it.
 
  


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
run custom script at boot time on IPcop lothario Linux - Networking 1 06-24-2008 08:54 PM
Is a script, run at boot time from init.d, run with root authority? tmbrwolf53 Linux - Server 2 03-31-2007 08:15 PM
RH8 - how to automatically run a shell script at boot time nu-B Linux - Newbie 2 11-03-2003 02:47 PM
RH8 - how to automatically run iptables rules shell script at boot time nu-B Linux - General 1 10-29-2003 08:38 PM
i want to run a script or program at boot time!! FreakboY Linux - Newbie 9 10-12-2003 08:03 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 05:36 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