Linux / UNIX Tech Support Forum
This is a discussion on Automate command execution - reboot-command execution within the Shell scripting forums, part of the Development/Scripting category; Hi All, Is there a way to execute some command and then after the command completes automatically reboot the system ...
|
Register free or login to your existing account and remove all advertisements. |
|
|||||||
| Shell scripting You can discuss the shell scripting, request shell scripts and scripting techniques |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Hi All,
Is there a way to execute some command and then after the command completes automatically reboot the system and then after the system reboots execute another command ? For example look at the sequence shown below (1) Execute command-1 (2) After the command-1 in (1) is completed,reboot the system (3) Execute command-2 (4) After execution of command-2 reboot the sytem Is there a way i can automate this process so that i need not reboot the system manually Thanks and Regards Ganesh |
| Sponsored Links | ||
|
|
|
||||
|
Write a shell script
Code:
command-1 && /sbin/reboot
__________________
Vivek Gite Linux Evangelist |
|
|||
|
Hi All,
Thank you very much for your kind support. The Linux distribution i am using is SLES 10 SP1. I would like to list some of the things that i found out in the course of solving this issue. boot.local runs before the runlevels are entered after.local runs after entering the final run level halt.local runs on the system halt To solve the problem in my hand i created a file called "to_do.sh" and then executed this file from file "after.local". File "after.local" was not present in /etc/rc.d/ folder. I created this file and added the line "sh /tmp/to_do.sh" in this file. Content of my "to_do.sh" is given below. With this i was able to achieve my requirement. Thank you, Regards, Ganesh Content of my "to_do.sh"In this file i am reading the choice after reboot from a file called choice.txt and after the current choice is executed i am rewriting my next choice to choice.txt for the next reboot. #!/bin/sh current_choice=$(</tmp/choice.txt) if [ $current_choice -eq 1 ] then #Step-1 Execute my command-1, write the command to execute below #Step-2 Change the choice ,so that in next reboot the elif gets executed echo "2">/tmp/choice.txt #Step-3 reboot reboot elif [ $current_choice -eq 2 ] then #Step-1 Execute my command-2, write the command to execute below #Step-2 Reboot and run echo "3">/tmp/choice.txt #Step-3 reboot reboot else echo "Completed">/tmp/Comp.txt fi |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Pause script execution untill each line is complete | cosminnci | Shell scripting | 4 | 11-12-2008 07:49 PM |
| script to automate download and rename | wademac | Shell scripting | 0 | 04-15-2008 12:51 AM |
| command run after reboot | kasimani | Shell scripting | 1 | 03-22-2007 01:45 AM |
| speeding up execution | kavi | Linux software | 6 | 10-16-2005 05:31 PM |
| How to Automate System Updates? | lynx noob | Linux software | 1 | 06-24-2005 12:14 AM |