Delay gnome shutdown/restart


 
Thread Tools Search this Thread
Operating Systems Linux Delay gnome shutdown/restart
# 1  
Old 12-21-2010
Delay gnome shutdown/restart

Hi to all.
My first message here, but i following you via twitter feed from many time...

The question:
I need to delay 5-10 seconds the shutdown command executed when the user click on the power off/reboot in their session or at login screen.

I need that because i have in the background a process that need to comunicate with a remote MySQL server login or logout of the users. In the normal case the shutdown process bring the network interface down before the local script can set a new logout record on DB.

I don't know what gnome execute when system is halted o rebooted.

I have tried this solution:
mv /sbin/shutdown /sbin/shutdown.bin

pico /sbin/shutdown
Code:
sleep 10
/sbin/shutdown.bin "$1" "$2" "$3" "$4" "$5"

...but strangely the system wait 10 seconds then reboot even when i call shutdown from gnome...

Any help is greatly appreciated Smilie

Greetings from Italy.
# 2  
Old 12-21-2010
If you strace the gnome into a file, you might find a point more upstream and effective.

Once you find it, you can create an IPC dialog of some sort to ensure the logout is in the DB.

Otherwise, have a server poll for logged in processes and log when they disappear, from the DB end.

Maybe MySQL has a facility when connections are made and broken that can or does log this.

Last edited by DGPickett; 12-21-2010 at 10:35 AM..
# 3  
Old 12-21-2010
How can i (s)trace what gnome do when call shutdown, the point is that need to intercept this signal, delay, then execute original signal...
# 4  
Old 12-21-2010
How is your background process started, and how do you signal it to log out? Maybe a service script in /etc/init.d (with appropriate entries in the required runlevel(s)) would solve your problem better than tinkering with shutdown.
# 5  
Old 12-22-2010
The script is launched via event.d (ubuntu 10.04)

/etc/init/checkuser.conf
Code:
description     "checkuser"
start on runlevel [2345]
respawn
exec /var/scripts/checkusers.sh

How can manage the shutdown of Pc making sure that this script report to mysql the logout of the user before shuttingdown?
# 6  
Old 12-22-2010
I'm not that fit with upstart, but as far as I know the MySQL startup script can be made a dependency of your script. I think (but not sure) that the line should be something like this:
Code:
start on net-device-up IFACE=eth0 #example
stop on runlevel [01S6]

This should start your script as soon as the network interface becomes available, and stop it when the system starts to shutdown/reboot.
# 7  
Old 12-22-2010
ok,
currently don't have declared any stop @ runlevel for this process.

The script must have the time to intercept the disconnection of 'user, which normally happens at shutdown.

At this point we think we need to play with the times, allowing the script to understand that the 'user is no longer connected and communicate to the MySQL server, the first turning off or disable the' network interface

Remember, the script generates a loop that repeats every three seconds to 'inside of which are recognized as the users who are connected or disconnected .. and communicates with mysql..
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Loop without a delay

Hi, I am trying to understand what would happen if ther is a loop without any delay like sleep statement, I feel that would add a lot of load onto the CPU. Trying to understand how the load is reduced by the introduction of sleep(). Thanks and regards Zulfi (3 Replies)
Discussion started by: zulfi123786
3 Replies

2. UNIX for Dummies Questions & Answers

Delay with Wget

I have a list of URLs that I need to download in a file. I know I can use the -i option to load the URLs from the file, but how can I make Wget wait a couple secs between each URL download? (4 Replies)
Discussion started by: rlopes
4 Replies

3. Shell Programming and Scripting

Backup & restore Gnome Desktop and all settings in Gnome

Hi I'm looking for scripts to backup & restore Gnome Desktop and all settings in Gnome. (0 Replies)
Discussion started by: ccc
0 Replies

4. Emergency UNIX and Linux Support

Shutdown to a Halt and restart

I've got critical patching this weekend on 6 HP UX machines, back to back and the customer has requested to shutdown, and halt the machines and to bring it up at a later period. The thing is the servers are located offshore and we are just the support team. I have a special login thru a console... (16 Replies)
Discussion started by: hedkandi
16 Replies

5. UNIX for Dummies Questions & Answers

Script to force Oracle database shutdown when shutdown immediate does not work

I have Oracle 9i R2 on AIX 5.2. My Database is running in shared server mode (MTS). Sometimes when I shutdown the database it shutsdown cleanly in 4-5 mints and sometimes it takes good 15-20 minutes and then I get some ora-600 errors and only way to shutdown is by opening another session and... (7 Replies)
Discussion started by: aixhp
7 Replies

6. Solaris

Restart/Shutdown the Solaris from SC>

Hi Experts, I am running solris 9. Sun-Fire 880. How do i shutdowon the whole server using ALOM i.e sc> console. If the server is down or somehow hang How do i Restart from sc> //purple (6 Replies)
Discussion started by: thepurple
6 Replies

7. Programming

Introducing Delay less then a second.

Hi, I have a doubt in introducing a delay in the programs. We know that we do have a sleep() function/api using which we can bring a delay in terms of seconds. A minimum delay can be atleast 1 second. Now I'm bothered about how to introduce a delay that is just less than a second. Like... (3 Replies)
Discussion started by: S.Vishwanath
3 Replies

8. UNIX for Dummies Questions & Answers

Delay in mv

Working on AIX 4.3 I have an active exe that accepts files for processing on our RS6000. Day to day i store these files in a secure place and at the end of the day I mv them one by one. After some reading and ofcourse trial and error i figured out that this helps... mv `ls -l |head -l | awk... (2 Replies)
Discussion started by: buRst
2 Replies
Login or Register to Ask a Question