startup script wont start up


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers startup script wont start up
# 1  
Old 11-05-2006
startup script wont start up

I've put this script in /etc/rc.d and made a symbolic link to it from S99pctb in /etc/rc.d/rc3.d but it wont start up. Anyone know why ?

This is the script:

---------------------------
#!/bin/sh
c=1

case "$1" in
start)
echo -n "starting pctb ..." > /etc/logger
while [ $c -lt 10 ]; do
x=`/bin/date -u +%k`
y=`expr $x + 1`

case $y in
0|1|2|3|4|5|6) /sbin/shutdown -h "now";;
*);;
esac

/bin/sleep 5

done
;;

stop)
;;
esac
--------------------------------------------------

Marcus.
# 2  
Old 11-05-2006
What exactly do you want to do in this script? It looks like you are trying to shutdown the system if the time is between 0100 to 0700 UTC you want to shutdown and halt the system.
Is that what you really want?

Also, are you sure that your script is actually running? Maybe you could have the script echo something to a file in the / directory right at the start to make sure of that.
# 3  
Old 11-05-2006
doesn't start up

That's right. i want to make the machine unavailable at night.

I've tried echoing to a file at the start, and it doesnt happen so it seems that the script just isn't starting at all.
# 4  
Old 11-05-2006
if you want to shut the system down when its between 1 and 7 o'clock, you should rather make a cronjob an run it every half our

then you have a chance to stop it in case you try to start the machine for any reason in the night

if you are the only person that uses this machine, rather make something like

0 0 * * * /sbin/shutdown -h now >> /etc/logger 2>&1

in /etc/crontab

why do you use arguments? when you don't want to start the script simply don't run it Smilie I'm confused ^^
# 5  
Old 11-05-2006
Since the script only works when the system is powered up, I think he wants the system to power back off if someone happens to turn it on after he's gone home.

Two things to look for. Is the script executable? Is run level 3 your system init level. Check /etc/inittab and see what your init:3:initdefault line is set to. If the number is '2', then you aren't getting to run level 3 and the script won't run.

Solaris (for example) goes through the run levels until it reaches the one set with init. So if inittab is set to run level 3, it runs through 2 running scripts and then processes scripts in 3.

Linux reads the run level and goes directly to the rc directory and processes the scripts. So you need to have links in each of the directories (rc2.d and rc3.d for example).

So if it's linux and the inittab is pointing to run level 5 as the initdefault, you'll need to link the script into /etc/rc5.d.

Carl
# 6  
Old 11-05-2006
May I suggest simply bringing down the network interface rather than shutting down the system? Then, in the morning, bring it back online. This, of course, does not prevent console access but, quite frankly, shutting down the box doesn't either (it just takes longer).
# 7  
Old 11-05-2006
Resolved

Many Thanks to all for the input. In the end I used the easiest method. I put * * * * * in the crontab file to run the command every minute.

Is there something I need to do to register this thread as resolved ?
Marcus.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Startup script wont execute on NAS

Hi, So I've created /etc/rc.local #!/bin/sh polipo -c /opt/etc/polipo/polipo.conf exit 0 if I run it with ./rc.local it does what its supposed to do and the proxy starts but not at startup. any idea whats wrong? thanks (1 Reply)
Discussion started by: deon
1 Replies

2. Shell Programming and Scripting

Apache tomcat startup script not booting at startup.

I copied the script from an AskUbuntu post - #!/bin/bash ### BEGIN INIT INFO # Provides: tomcat7 # Required-Start: $network # Required-Stop: $network # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Start/Stop Tomcat server ### END INIT INFO ... (14 Replies)
Discussion started by: Hijanoqu
14 Replies

3. SuSE

start services during the startup

I'm trying to add services to start services automatically during the system start up in suse linux. I followed these steps.. chkconfig servicename on and created symbolic link at /etc/rc.d/rc3.d/ folder with name S80servicename. here is the command I used ln -s /etc/init.d/servicename... (8 Replies)
Discussion started by: s_linux
8 Replies

4. Solaris

StartUP file to start a service

Hi guys: i have a Solaris 10 development server and a Solaris 9 production server. The entire task must be done in the dev. server. When it's done and all the testing is OK, the script or files are transfer to prod. Server. All right. Now I have to figure out a way to put a script to initiate... (2 Replies)
Discussion started by: bmathiasf
2 Replies

5. UNIX for Advanced & Expert Users

Xwindows wont start

I have one machince where X crashes with some weird error on boot... Fatal server error: Cannot move old logfile "/var/log/XFree86.0.log.old" This is running redhat enterprise ES 3, I cant figure out how to get past this error. I have tried deleting the logfiles and recreating them, however... (1 Reply)
Discussion started by: frankkahle
1 Replies

6. Solaris

stop a process to start at system startup

Hi all! I'm running Solaris 10 and have a question about how i can stop a certain program to start at system startup,for example, as it is now sendmail is starting but i don't need sendmail,on the other hand so would i be very glad to get cups up and running at startup, anyone who can explain where... (3 Replies)
Discussion started by: larsgk
3 Replies

7. UNIX for Advanced & Expert Users

AIX 5.3: Start Service on System startup

Hi, I'm new to AIX, and have to make some services start at system startup. The IBM-Redbook says I have to edit /etc/inittab. As a long time (Debian)-Linux Admin I'm a bit confused. Is there something like /etc/init.d/$SERVICE in AIX? Greetings, Dennis (1 Reply)
Discussion started by: dennis.kuehl
1 Replies

8. Solaris

SMC wont start

Today I attempted to use SMC for the first time on SUNSVR01 since 4 November. The SMC toolbox loads just fine but when I attempt to run any of the tools in SMC, I get red stop signs with labels like "com.sun.admin.hostmgr.client.vhostmgr" in the GUI. At the bottom of the screen, I get the... (0 Replies)
Discussion started by: wjseaman
0 Replies

9. UNIX for Dummies Questions & Answers

how do i auto start application upon startup?

sorry, i'm a newbie to unix... but how do i or rather where do i write scripts that auto start my application e.g. Informix? in Windows it would be services but in UNIX where can i auto start my informix program? To run informix i just type "oninit". And do i have to login to any user before... (2 Replies)
Discussion started by: doofie
2 Replies

10. UNIX for Dummies Questions & Answers

Apache wont start

Hi, like a lot of people that post here, I am new at UNIX. The only UNIX I have ever messed with is my iBook running MacOSX (10.1). I have a grasp of the basic commands and understanding of the system but only to a point. I searched the archive and FreeBSD.org and apache.org but I couldn't find... (4 Replies)
Discussion started by: Alpha_Harblo
4 Replies
Login or Register to Ask a Question