1

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.

Thanks!

1 Answer 1

1

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:
    do_this()
    rebooted = True
    save_bootflag(rebooted)
    shutdownroutine()
else:
    do_that()
    rebooted = False
    save_bootflag(rebooted)

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

3
  • Thanks. Did this with a "reboot.txt" file, some read file and if statements.
    – Eden Crow
    Apr 15, 2011 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, 2011 at 12:37
  • unless you do a trick with autostarting some app that checks this.
    – Takkat
    Apr 15, 2011 at 13:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .