Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am creating a quick python3 program and at one part the server will need to be restarted. The thing is, that is not the end of the what the python file is supposed to do. Is there a way to make it start up from where it stopped when the user restarts or (if that isn't possible) automatically open a 2nd python file, which will continue with the rest of the task required.


share|improve this question
up vote 1 down vote accepted

A reboot of the server obviously will also kill all running applications. Therefore we need to create a file on the harddisk that survives this.

This file only needs to flag whether the server is going to reboot or if it was just rebooted like:

rebooted = False
rebooted = True

We then let our application run different paths like:

rebooted = load_bootflag()
if not rebooted:
    rebooted = True
    rebooted = False

Where load_bootflag() and save_bootflag() are your routines to create this file.

share|improve this answer
Thanks. Did this with a "reboot.txt" file, some read file and if statements. – Eden Crow Apr 15 '11 at 12:00
But that still means I'm going to have to ask the user to reopen the file after restart. – Eden Crow Apr 15 '11 at 12:37
unless you do a trick with autostarting some app that checks this. – Takkat Apr 15 '11 at 13:34

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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