when logging out to a different user, shutting down, or restarting the machine sometimes I can get this message

some programs are still running

program list

waiting for programs to finish. interrupting these programs may cause you to lose work

Is there any way that ubuntu can automatically detect when these programs have completed their task before closing down? I understand there is an issue with programs that might have crashed. But some other programs such as Ubuntuone might need some additional time to sync before the system can shutdown

Here you are, this is the parse output. I have got no clue of what can be done with it, but I am quite excited to see some magic!

martin@ubuntu-desktop:~$ u1sdtool --status
    connection: With User With Network
    description: processing the commands pool
    is_connected: True
    is_error: False
    is_online: True
    queues: IDDLE

the only difference when the daemon is syncing is the last line that can become

queues: WORKING



I am not sure if that would be nice, can you imagine if you had to w8 for 1Gb of files to be synced before shutdown? Doesn't it make more sense that the close signals are sent to the programs so they can quit and if there is further work then it can be resumed on after booting again.

Even Windows only allows 30 secs before it forces close on programs for shutdown.

I really don't see how can this be useful! If I order a shutdown I want that thing closed asap and boot up asap, not wait for the programs to do idontknowwhat. After all, it was my responsibility that started the shutdown, I should know when its a good time or not.

Edit (read all the comments bellow!):

Here is the script that checks the current status of UbuntuOne and shuts down only when status is idle.

#! /bin/bash


while true; do
    u1sdtool_status=$(u1sdtool --status | grep -o 'queues: IDLE')
    timestamp=$(date +%H:%M:%S)
    if [ "$u1sdtool_status" = "queues: WORKING" -o "$u1sdtool_status" = "queues: WORKING_ON_BOTH" ]; then
        echo "$timestamp - UbuntuOne has not finished sync, waiting for conclusion."
        echo "Re-checking in 30 seconds."
        sleep 30
    elif [ "$u1sdtool_status" = "queues: IDLE" ]; then
        if [ $gracetime_given = false ]; then
            echo "u1sdtools seems to be idle at the moment..."
            echo "Giving u1sdtool some grace time, rechecking in 10 seconds."
            sleep 10
            echo "This is where you shutdown!!!"
            sleep 5
            sudo shutdown -h now
        echo "Something is really wrong!!!"

To use it you need to do the following, on the terminal you need to use sudo visudo and add this line at the end of the file <yourusername> hostname=NOPASSWD: /sbin/shutdown -h now so that no password is necessary to shutdown your computer using account.

After that you need to save the script anywhere (), you need to use chmod 755 <nameofthescript.sh> to make it executable.

Then you can just run the scrip and see how it works:

  • gets the current status of UbuntuOne
  • if not idle re-checks to see if its idle every 30 secs
  • if idle will give it 10 more secs and recheck if the status is still idle
  • if it is still idle it will shutdown using shutdown -h now

Hope this works and comment as you want on the code as long as you understand that this is actually my very first bash script!

Gl and hf ;)

  • I understand your point. But don't forget that ubuntu one is also a service that allows to keep more computers synced. Someone might work in an office and want to share files on their laptop and home computer. Let's say that it's 5pm, they finish the work day, UbuntuOne is still syncing a few files and it's got another 5-10 minutes till it ends. It's quite unfortunate to have to wait, and at the same time it's not good to leave the machine on overnight or over the weekend. The solution must be found in UbuntuOne then. I was just wondering if anyone knew of a tweak – Martin Sep 29 '11 at 22:25
  • No, if something is not finished the "task" should stay in the queue for the next reboot. So if your syncing 1Gb of files and you issue a shutdown at 500Mb the process will be interrupted and it will resume again when you boot up. That is more logical I think, no? Understand were you are going but I dont know anyway to calculate how much time is necessary to sync or a hook that prevents shutdown based on a program status. – Bruno Pereira Sep 30 '11 at 9:29
  • 1
    I do know how to make your computer shutdown later then the shutdown command. "shutdown -h" will make your computer shutdown. "shutdown -h 10 Waiting 10 minutes before the shutdown&" will make your computer shutdown in 10 minutes and broadcast a message saying "Waiting 10 minutes before shutdown" to all users. It will also prevent users from logging, this has to be issued with root privileges. – Bruno Pereira Sep 30 '11 at 9:35
  • 1
    "shutdown -h 18:00 Shutdown scheduled for 18:00 hours&" will make your computer shutdown at 18:00, will broadcast Shutdown scheduled for 18:00 hours to all users and will prevent users from logging, can be cancelled with "shutdown -c" issued by root user or user with privileges. Hope this helps, let me know if it was useful or not ;) – Bruno Pereira Sep 30 '11 at 9:39
  • 1
    If you get me a output file of the u1sdtool --status while syncing and while while maybe a script can be born out of this ;) – Bruno Pereira Sep 30 '11 at 14:58

There is a dialog that appears when you're exiting gnome-session and there are applications that just won't quit, but I don't remember if it allows you to postpone shutdown until a certain process finishes. I don't believe it does, but it shouldn't be too difficult to add that, I think.

As others have pointed out, you can wait a certain amount of time or until a certain point in time before you shut down the system. Another thing you can do, it so write a custom script for it, but I would not exactly be shocked to learn that someone had written an app for this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.