Reboot script issue


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Reboot script issue
# 1  
Old 11-11-2012
RedHat Reboot script issue

Hi guys

I am troubleshooting a script that informs me when a system has rebooted.

The script is placed in /etc/rc3.d folder under root.
The script is as follows:

Code:
. /opt/scripts/function.sh
PATH=/usr/bin                            
EMAIL_ADD=<email address>      
#-------------------------------------------------------------------------------


echo "$WT_SYSTEM is rebooted" | mailx -s "SYSTEM is rebooted" $EMAIL_ADD


Func_SMS " SYSTEM is rebooted"

function.sh is used to send a sms to my cell number.

The problem I am facing is that when I execute the script like this : ./Script ,
it returns with the following error : syntax error at line 14: `}' unexpected

But when I rin it like : ksh -x Script , it works..... What is the issue here ?

Regards
# 2  
Old 11-11-2012
I don't see neither line 14 nor a "}" in your script, so pls be more specific: post entire script, post log of execution includig messages.
# 3  
Old 11-11-2012
You should specify the shell on the 1st line of the script.

Also it's not wise to put scripts directly into /etc/rc3.d
you are better off putting a chkconfig compatable script into /etc/rc.d/init.d and using chkconfig to create the required sym links

Try this scrip, save it as /etc/rc.d/init.d/stnotify
Code:
#!/bin/sh
#
# stnotify        Notify sysadmin system startup
#
# chkconfig: 2345 87 03
# description: Send SMS to sysadmin when system starts.
#
 
. /opt/scripts/function.sh
PATH=/usr/bin                            
EMAIL_ADD=<email address>      
 
#-------------------------------------------------------------------------------
 
case "$1" in
    start)
        echo "$WT_SYSTEM is rebooted" | mailx -s "SYSTEM is rebooted" $EMAIL_ADD
        Func_SMS " SYSTEM is rebooted"
     ;;
     stop) ;;
     *) echo "Usage: $0 {start|stop}"
        exit 1
esac

Then use chkconfig --add stnotify to install your script (it will create symbolic links for the start and stop version of the script at the required run levels).

Note the same script could be enhanced to notify you if the system is restarted, shutdown or put into single user mode.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Linux

Issue in Bonding during Reboot(Linux)

Respected Members, We encountered an issue during node reboot when eth1 and eth5 of bond1 were behaving unusual(both eth1 and eth5 were in unknown states and ifdown and ifup were used to rectify). Please find the messages and configuration files as below and please let me know for any other... (0 Replies)
Discussion started by: Mudit Bansal
0 Replies

2. IP Networking

Node switched itself from static to DHCP on reboot issue

I'm trying to figure out what circumstances would cause an Open Solaris 11.2 host to switch itself from a static to a DHCP ip address upon reboot. This has only happened once but is a cause for some concern as this machine will be part of a web server pool. Nothing has changed on the LAN that... (2 Replies)
Discussion started by: SmokeyJoe
2 Replies

3. Shell Programming and Scripting

Remote reboot script

I'm a beginner in shell scripting and doing simple scripts for work requirement. #!/bin/bash for blade in `cat machines.txt` do rsh $blade 'reboot' done but when I try it with root password it's throwing error saying permission denied.We're using same root password for all... (3 Replies)
Discussion started by: ratheeshp
3 Replies

4. Solaris

vnc issue after reboot

Hi , Everytime after reboot when user tries to start vnc below error is thrown $ vncserver :5 Couldn't start Xvnc; trying default font path. Please set correct fontPath in the vncserver script. Couldn't start Xvnc process. _XSERVTransSocketCreateListener: failed to bind listener... (7 Replies)
Discussion started by: chidori
7 Replies

5. Shell Programming and Scripting

Script to Reboot and Confirm

On my Solaris box I have to reboot some devices like below. However I think this can be done through a script. I've create a list that contains the devices IP addresses. Here's the logic: Reboot 4 devices and sleep for 5mins(300s.) While the devices are rebooting, I would like to confirm... (9 Replies)
Discussion started by: ravzter
9 Replies

6. Solaris

Controller Issue on X4600 after reboot

One of my X4600 server had a power loss and rebooted and now its giving me a strange problem servers internal disk controller naming has changed by itself ... the after failsafe boot md.conf file shows following c3txdx but shows internal disk at c4txdx ... what could be the reason for this and... (1 Reply)
Discussion started by: fugitive
1 Replies

7. SCO

SCO Reboot Issue

Hi, We are using SCO UNIX 7.1.3 and the server recently started rebooting by itself. Do anyone know how can i create a dump or crash dump while the server rebooots? Your quick help on this is really appreciated. Regards, Ravikumar R (1 Reply)
Discussion started by: rrb2009
1 Replies

8. HP-UX

Issue in reboot

Hi, Whenever I reboot this server remotely by using the command 'shutdown -r now' or 'reboot'. The server does not return to normal multi-user mode. It boots in single user mode. To bring back the server, someone is required to connect via console and fire 'init 3'. Please suggest on what... (1 Reply)
Discussion started by: mystition
1 Replies

9. Linux

Run a script during reboot/startup

Hi all, i have a script in /etc/init.d directory. -rwxr-xr-x 1 root root 26 Mar 28 16:00 myscript I need it to run when my linux reboots/startup. However is it not being executed. Do i need to put in in the rc.local directory? (1 Reply)
Discussion started by: new2ss
1 Replies

10. Solaris

different between soft reboot and hard reboot

Hi Guru's Can any want here could explain to me the different between soft reboot and hard reboot . Best Regards Seelan (3 Replies)
Discussion started by: seelan3
3 Replies
Login or Register to Ask a Question