LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-17-2012, 06:50 AM   #1
alieblice
Member
 
Registered: Jul 2011
Posts: 80

Rep: Reputation: Disabled
inittab doesn't execute my command


Hi

i tried to add one line to /etc/inittab that execute a command when it enters runlevel 1
i add this line but its not working.

Code:
time:1:once:/usr/bin/uptime > /home/uptime
and after adding above line i run this command
Code:
telinit Q
but when i change runlevel to 1 it seems not working.
 
Old 12-17-2012, 07:23 AM   #2
jmc1987
Member
 
Registered: Sep 2009
Location: Oklahoma
Distribution: Debian, CentOS, windows 7
Posts: 872

Rep: Reputation: 112Reputation: 112
Ubuntu uses upstart. Try adding it too

/etc/init/rc-sysinit.conf
 
Old 12-17-2012, 07:30 AM   #3
alieblice
Member
 
Registered: Jul 2011
Posts: 80

Original Poster
Rep: Reputation: Disabled
thanks for reply .

it's not Ubuntu
it's Debian and my debian doesn't have upstart.
UPDATE
i found out that this problem is only happen for runlevel 1 . if i change my line for runlevel 4 its working.
Code:
time:4:once:/usr/bin/uptime > /home/uptime
can any one tell me why its not working for runlevel 1 ?

Last edited by alieblice; 12-17-2012 at 07:58 AM.
 
Old 12-17-2012, 10:40 AM   #4
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,396
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Is the appropriate partition (/home) mounted in runlevel 1?
--- rod.
 
Old 12-18-2012, 07:58 AM   #5
alieblice
Member
 
Registered: Jul 2011
Posts: 80

Original Poster
Rep: Reputation: Disabled
thanks for reply
home isn't on a separate partition . all the system is installed on 1 partition.
 
Old 12-18-2012, 10:51 AM   #6
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,637

Rep: Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251
Try marking it for single user mode - "s", rather than "1".

Some versions treat runlevel "s" as equivalent to, but not the same as "1".

Your entry would then become:
Code:
time:s1:once:/usr/bin/uptime > /home/uptime
so as to cover both cases...

Last edited by jpollard; 12-18-2012 at 10:52 AM.
 
Old 12-18-2012, 10:55 AM   #7
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,637

Rep: Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251
As a short followup, what you are doing is fine for testing... but it will not record anything if the system shutdown normally (going to a halt) because it never goes into single user mode - it goes instead to a halt (runlevel 0).
 
Old 12-18-2012, 11:46 AM   #8
alieblice
Member
 
Registered: Jul 2011
Posts: 80

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by jpollard View Post
Try marking it for single user mode - "s", rather than "1".

Some versions treat runlevel "s" as equivalent to, but not the same as "1".

Your entry would then become:
Code:
time:s1:once:/usr/bin/uptime > /home/uptime
so as to cover both cases...
i add 's' and 'S' to it but no change happened.looks like its not going to working for runlevel 1.

yes its for testing and learning purpose but i wondering why it's not working for runlevel 1 but its work fine for runlevel 2 to 5 .
 
Old 12-18-2012, 06:12 PM   #9
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,637

Rep: Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251
Looking at some code.. it treats "Ss1" the same - and differently than 2-5 (six is another special case)

It looks like it only sets up the console tty... Then it goes through a restart and process the initab (which would start/stop anything needed) but not do anything for single user mode. Now this is based on a fairly quick look, so I could still have overlooked something.

Good question and observations.

The code I'm looking at is sysvinit-2.88dsf. I don't know which exact version your system is using, but I believe it is based on this one.

Last edited by jpollard; 12-18-2012 at 06:13 PM.
 
  


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
Execute a command , reboot and then execute another command ganeshp@moris.org Linux - Newbie 3 12-03-2008 01:51 AM
cron daemon doesn't start from inittab, but says already running!! AbrahamJose AIX 1 09-19-2008 05:52 AM
Inittab: Command for switching display to tty2/3/4/... chochem Linux - Newbie 2 09-06-2008 12:43 PM
CTR+ALT+DET /etc/inittab doesn't execute ? knockout_artist Linux - Newbie 9 04-02-2008 02:48 PM
Standby mode for drive, where does command go? inittab? Eradicator Mandriva 1 04-16-2004 09:35 AM


All times are GMT -5. The time now is 05:34 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration