Run a script before and after reboot automatically and send output to two locations.


Login or Register to Reply

 
Thread Tools Search this Thread
# 1  
Run a script before and after reboot automatically and send output to two locations.

Hello Team .

I am working a health check script ( bash) to run on linux server ( RedHat) and requirements are
1. The o/p of script need to be send to two diff files . I am testing with tee command . But I am not successful yet , any recommendations if that is the right approach ?
2. The same script need to run by itself just before power off and right after power on . If I keep the script under /etc/init.d , it will run right after power on OR to set up a cron with @reboot . But what I am looking is if I can have a logic in script which need to identify whether the state of the server is power off or on , If so send the output from one of the o/p files generated(from #1) .

Hope it makes sense.

Last edited by Varja; 1 Week Ago at 07:05 PM..
# 2  
Greetings and welcome to our forum
Quote:
, it will run right after power on .
depends what you call right after...
Without knowing your OS and its version no one will take the risk of giving you any advise, as start stop implementation is OS dependant
# 3  
my apologies. I will edit to make it more clear.

--- Post updated at 11:08 PM ---

Quote:
Originally Posted by vbe
Greetings and welcome to our forum

depends what you call right after...
sorry, not sure If I got you right , I was referring to the script I am (still) working on on the whole context.
Login or Register to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
A shell script to run a script which don't get terminated and send a pattern from the output by mail
Sambit Sahu
Hi Guys, I am very new to shell script and I need your help here to write a script. Actually, I have a script abc.sh which don't get terminated itself. So I need to design a script to run this script, save the output to a file, search for a given string in the output and if it exists send those...... Shell Programming and Scripting
11
Shell Programming and Scripting
How to run script automatically on reboot as root user?
Akshay Hegde
Hi friends,,, I am running one server on Ubuntu 12.04 LTS 32-bit, some times my pc restarts automatically, with no reason, I have a script to start server which requires root password. in this directory /myserver/start_server.sh How can I do this ? and some scripts I am having that I...... Shell Programming and Scripting
1
Shell Programming and Scripting
how to run a script using cron job and send the output as attachment via e-mail using unix
vidhyaS
how to run a script using cron job and send the output as attachment via e-mail using unix. please help me. how my cron job entry should be? As of now my cron job entry is to run the script at specific time, 15 03 * * * /path/sample.sh | mail -s "Logs" email_id In the above entry, what...... Shell Programming and Scripting
8
Shell Programming and Scripting
How to automatically send a mail alert if the script errors out
ss3944
I have a script like this, which calls other scripts from that script: #!/usr/ksh moveFiles.sh extract.sh readfile=/home/sample.txt cat $readfile | while read line do file= `echo $line|awk '{print $4}'` if ; then mv $file /home/temp_stage fi... Shell Programming and Scripting
4
Shell Programming and Scripting
Script to automatically reboot to newly compiled kernel with fallback
tridus_08
Hi, I'm new here. Just started playing around with kernel compilation. I need a little bit of advice. I'm trying to do a bash script to automatically compile a kernel package and reboot to that new kernel by default, with fallback to the old kernel. So far, I'm getting stuck at the part...... UNIX for Dummies Questions & Answers
0
UNIX for Dummies Questions & Answers