Archives for January 2013

Using nohup for existing processes

Most of you are probably aware with the fact that by default any processes you may have running within your session will be killed once you terminate the session. The most common example is logging onto a remote server via SSH, starting some command and then closing the terminal session.

As you know, this happens because when your’e terminating your shell it ends up sending the SIGHUP signal to all the child processes, notifying them about the end of the session and therefore instructing them to wrap up whatever it was they were doing and to terminate.

Many are also aware of the wonderful nohup command which adds flexibility to start any command in a mode where it will ignore the SIGHUP and therefore stay running (and writing output to log files, for example) even after your terminal session completes.

Basic usage of the nohup command

Here’s how you should use it:

$ nohup ./ &
Sending output to nohup.out
[1] 3763

What this does is put your script into background while making it ignore SIGHUP signals in the past. The background element is not necessary but very common because if you expect something to be running for hours/days – you probably don’t want to be watching it in your terminal anyway. So you put the task into background.

The [1] indicates that this is the first (and only) job you’re running in background so far. The 3763 is the process ID (PID) of the script.

Output redirection into nohup.out

nohup command redirects all the standard input into nohup.out file so if you’re interested in your script’s output you can still keep an eye on it this way:

tail -f nohup.out

nohup for an existing process

In recent versions of Solaris 10 the nohup command has seen a really welcomed addition: it now allows you to make any process (within your privileges of course) ignore SIGHUP signal. This is really convenient because if you started some script in the morning and by late afternoon it’s obvious that it won’t finish by the time you should be heading home – you can now simply use nohup command to update the process and allow it to finish even when you log out.

Another reason it’s so convenient is because prior to this feature the scenario described above would leave you no option but to keep your session open. If you couldn’t (for example you must disconnect your laptop every evening) – you had to stop the script and restart next morning (with nohup this time).

Here’s how you update an existing process:

-bash-4.1# nohup -p 3468
Sending output to nohup.out

or get a message suggesting you must elevate your privileges before you can do it:

greys@solaris:~$ nohup -p 3468
nohup: cannot examine 3468: permission denied

Using Service Controller to confirm battery status

I’ve been working with a support engineer on replacing an SC battery in one of T2000 servers recently, and noticed that immediately upon rebooting a server it may not be possible to get battery and fans stats because prtdiag command wouldn’t work (picld daemon not fully operating yet).

Turns out, there’s another way to get this info – simply use #. to get back into ALOM and run the showevnironment command. Among other things, it reports battery status:

sc> showenvironment
Voltage sensors (in Volts):
Sensor          Status      Voltage LowSoft LowWarn HighWarn HighSoft
MB/V_+1V5       OK            1.48    1.36    1.39    1.60     1.63
MB/V_VMEML      OK            1.79    1.63    1.67    1.92     1.98
MB/V_VMEMR      OK            1.79    1.63    1.67    1.92     1.98
MB/V_VTTL       OK            0.89    0.81    0.83    0.96     0.99
MB/V_VTTR       OK            0.87    0.81    0.83    0.96     0.99
MB/V_+3V3STBY   OK            3.33    3.13    3.16    3.53     3.59
MB/V_VCORE      OK            1.31    1.20    1.24    1.36     1.39
IOBD/V_+1V5     OK            1.48    1.36    1.39    1.60     1.63
IOBD/V_+1V8     OK            1.79    1.63    1.67    1.92     1.96
IOBD/V_+3V3MAIN OK            3.36    3.06    3.10    3.49     3.53
IOBD/V_+3V3STBY OK            3.33    3.13    3.16    3.53     3.59
IOBD/V_+1V      OK            1.18    1.09    1.11    1.28     1.30
IOBD/V_+1V2     OK            1.16    1.09    1.11    1.28     1.30
IOBD/V_+5V      OK            5.09    4.55    4.75    5.35     5.45
IOBD/V_-12V     OK          -12.11  -13.08  -12.84  -11.16   -10.92
IOBD/V_+12V     OK           12.06   10.92   11.16   12.84    13.08
SC/BAT/V_BAT    OK            3.37      --    2.25      --       --