-2

I have a long running process that was parsing text and my laptop died at some point because it was unplugged.

I really don't want to unnecessarily run the process again because it takes over a day, but I need to see if the process finished or not before the computer died. Is there any way to do this?

It was a python script

Joff
  • 504
  • 2
  • 6
  • 15
  • 3
    How can anyone guess without knowing what the command does? And you say bash command in the title and python script in the question. Which is it? – muru Dec 14 '15 at 00:23

3 Answers3

3

Typically, commands won't return a status code if they've been unexpectedly shut down, especially in the case of a power loss.

The best thing you can do is to see if the output (file or whatever) is there. If it is, then your process probably finished (or finished partially). If not, you're going to have to restart your task.

If this is your own code, I would highly suggest that you attach a debugger to your program. If it's someone else's and it's open source (it's Python so it should be), you can just add it in.

Kaz Wolfe
  • 34,122
  • 21
  • 114
  • 172
1

Not knowing what the script or command is/was makes it harder for me to answer, but as a general rule: If nothing outstanding enough to force the Operating System to log it happened, it's pretty much lost, as far as I know.

Good software developing practices involves writing "Debug" code, which will allow the program to leave messages about its own progress somewhere, either in a text file, or in /var/log/yourscriptname/last.log as example.

If your script contains such debugging code, those two links might be of use to you:

If there is nothing to be found, I would recommend reading the script to see if it contains debugging code, and if none is present, add something equivalent to Script finished at [time here] where needed.

Xenhat
  • 351
  • 1
  • 6
0

There's no general way to check if a given program was running when the system was shut down or died.

Depending on your program you may guess e.g. on the modification date of soem output files. If you want to be sure you should rerun the program.

If possible you probably could add some logging to the program so you know next time if it finished properly.