How to run script after hibernation ..

 
Thread Tools Search this Thread
Operating Systems Linux Red Hat How to run script after hibernation ..
# 1  
Old 04-29-2011
How to run script after hibernation ..

hello,
I am running rhel6 open client.
I have a firewall in my office at work and I have to authenticate to BSO every 4 hours. Instead of doing it manually I wrote a perl script which does this for me.
I placed that script in rc.local file and it get executed every time I restart system. The issue is that I mostly hibernate my system rather then reboot it and after restoring from hibernation rc.local doesn't run.
My question:where should I place my script to run it every time system restores from hibernation or other workaround?
thanks in advance ..
# 2  
Old 04-29-2011
Try putting your script in sleep.d.

This is the entry from my system (RHEL 5):

Code:
[verdepollo@atlas]~% cat /etc/pm/sleep.d/99sleep-script
#!/bin/sh
case "$1" in
   suspend|freeze)
	echo "Sleeping..."
   ;;

   resume|thaw)
	echo "*Yawn*"
   ;;

   *)
   ;;
esac


Last edited by verdepollo; 04-29-2011 at 11:53 AM..
# 3  
Old 04-30-2011
Quote:
Originally Posted by verdepollo
Try putting your script in sleep.d.

This is the entry from my system (RHEL 5):

Code:
[verdepollo@atlas]~% cat /etc/pm/sleep.d/99sleep-script
#!/bin/sh
case "$1" in
   suspend|freeze)
	echo "Sleeping..."
   ;;

   resume|thaw)
	echo "*Yawn*"
   ;;

   *)
   ;;
esac


hi verdepollo,
thanks for reply,
first I just put my Perl script into /etc/pm/sleep.d but after that system failed to get into hibernation state. Then I placed my Perl script inside your script like this:

Code:
#!/bin/sh
case "$1" in
   suspend|freeze)
	echo "Sleeping..."
   ;;

   resume|thaw)
#	echo "*Yawn*"
	/usr/bin/perl /home/evoldman/Scripts/BSO.pl
   ;;

   *)
   ;;
esac

and it started to work. Well I put inside rc.local my perl script and it worked just fine after reboot but here it looks it doesn't like it.
In any case now I think I covered 2 cases: 1. when it boots up it runs rc.local and 2. when it wakes up from hibernation it executes your script.
Thanks a lot for your help.

Last edited by pludi; 05-01-2011 at 09:33 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script run in a case statement call to run a php file, also Perl

Linux System having all Perl, Python, PHP (and Ruby) installed From a Shell script, can call a Perl, Python, PHP (or Ruby ?) file eg eg a Shell script run in a case statement call to run a php file, also Perl or/and Python file??? Like #!/usr/bin/bash .... .... case $INPUT_STRING... (1 Reply)
Discussion started by: hoyanet
1 Replies

2. Shell Programming and Scripting

Script fails to run properly when run from CRONTAB

Hello all, I'm trying to write a script to gather and send data and it works just fine at the bash command line, but when executing from CRON, it does not run properly. My scripting skills are pretty limited and there's probably a better way, but as I said it works at the command line, but... (12 Replies)
Discussion started by: rusman
12 Replies

3. Linux

Systemd hibernation is killing me

I'm on Arch and I have a strange issue with systemctl hibernate command. It hibernates and resumes just fine (I have TuxOnIce), but in the last stage of resume, it completely shuts down my laptop screen, so I cannot see anything even though I know the system resumed just fined and the desktop is... (1 Reply)
Discussion started by: lockheed
1 Replies

4. Shell Programming and Scripting

how to run an already made script run against a list of ip addresses solaris 8 question

how to run an already developed script run against a list of ip addresses solaris 8 question. the script goes away and check traffic information, for example check_GE-VLANStats-P3 1.1.1.1 and returns the results ok. how do I run this against an ip list? i.e a list of 30 ip addresses (26 Replies)
Discussion started by: llcooljatt
26 Replies

5. AIX

My script didn't run every run every minute at cronjob

In my cronjob, I would like to schedule my script.sh to run every minutes. I crontab -e and have in line below but it didn't seems to run at all. * * * * * script.sh When I run it manually, I can run it. Is that anything wrong with the above line? If I change it to something like below,... (4 Replies)
Discussion started by: ngaisteve1
4 Replies

6. Ubuntu

Losing wmx0 interface after waking up from hibernation

I don't know why, but I can't connect to my WiMax network after waking up from hibernation... System log shows the following messages: Feb 5 10:07:52 lenovo-S102 wimaxd: wimaxd event: libwimax: 6843 Feb 5 10:07:52 lenovo-S102 wimaxd: wimaxd event: E: RX: cannot join multicast group 0: -22... (4 Replies)
Discussion started by: Sapfeer
4 Replies

7. Red Hat

Can't find Hibernation in Rhel5

I've installed Rhel 5.1 in an intel quad core server. I couldn't find the Hibernation option. And can't find anything related to it in the power management options. Plz guide how to install hibernation or enable thise option. Thanks, Giri (1 Reply)
Discussion started by: giri_blr
1 Replies

8. Ubuntu

Ubuntu 9.04 hibernation

Hello everyone, I finally installed Ubuntu 9.04 64 bit using dual boot. Love it! :b: Now I have an issue with the hibernation, it just turns off the monitor instead of the whole system when I click. Is there some else I have to get done? please advice, Many thanks. (2 Replies)
Discussion started by: Pitroadrush
2 Replies

9. UNIX for Advanced & Expert Users

script to run different shells which run different processes

Hi, Would like to ask the experts if anyone knows how to run a script like this: dtterm -title shell1 run process1 on shell1 dtterm -title shell2 run process2 on shell2 cheers! p/s: sorry if i used the wrong forum, quite concussed after watching world cup for several nights; but I... (2 Replies)
Discussion started by: mochi
2 Replies
Login or Register to Ask a Question