LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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, 05: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, 06:23 AM   #2
jmc1987
Member
 
Registered: Sep 2009
Location: Oklahoma
Distribution: Debian, CentOS, windows 7/10
Posts: 893

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

/etc/init/rc-sysinit.conf
 
Old 12-17-2012, 06: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 06:58 AM.
 
Old 12-17-2012, 09:40 AM   #4
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
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, 06: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, 09:51 AM   #6
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
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 09:52 AM.
 
Old 12-18-2012, 09:55 AM   #7
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
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, 10: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, 05:12 PM   #9
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
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 05:13 PM.
 
  


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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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