Friday, January 14, 2011

No Screen?! Ok, Run Processes In The Background

I would hate for this post to become a rant (even though it kind of is), so I will just call this a "quick tip".

A Security Issue, But A New Headache For Screen Users

So, we implemented this new policy in our network where we cannot store our ssh keys on any server, they must be stored on your local computer only. Okay, that's fine, except for the fact that I like to take my laptop home and occasionally I need to run scripts that take a really long time to finish.

I used to be able to use this one server as a "gateway" to all of the other servers in our network. Luckily, screen is installed and I can just have a screen session open, run a process or two on any server, and then detach from the session, shutdown my laptop, go home, and check on it later.

But now with my laptop being the "gateway" I would either need to stay and wait for these processes to finish or risk aborting them when I log out.

nohup To the Rescue

Just a reminder, if you can't screen, there is always nohup and sending that process to the background!

Example: nohup some_process_or_script.sh &

I won't get into details, but here are some related/helpful commands to use along with this:
jobs, bg, fg

Check out their man pages and I'm sure you'll be happy that you can still be able to run processes before leaving the office and then check back on them later!

Cheers!

No comments: