Search code examples
bashforkpsnohup

Check status of a forked process?


I'm running a process that will take, optimistically, several hours, and in the worst case, probably a couple of days.

I've tried a couple of times to run it and it just never seems to complete (I should add, I didn't write the program, it's just a big dataset). I know my syntax for the command is correct as I use it all the time for smaller data and it works properly (I'll spare you the details as it is obscure for SO and I don't think that relevant to the question).

Consequently, I'd like to leave the program unattended running as a fork with &. Now, I'm not totally sure whether the process is just grinding to a halt or is running but taking much longer than expected.

Is there any way to check the progress of the process other than ps and top + 1 (to check CPU use).

My only other thought was to get the process to output a logfile and periodically check to see if the logfile has grown in size/content.

As a sidebar, is it necessary to also use nohup with a forked command?


Solution

  • I would use screen for this purpose. see the man for more reference Brief summary how to use:

    screen -S some_session_name - starts a new screen session named session_name

    Ctrl + a + d - detach session

    screen -r some_session_name returns you to your session