Context: I'm using bash in Mac OSX Yosemite.

Problem: I'm executing a (python) script that I expect to use alot of resources and take a few hours to run, redirecting stdout and stderr to a log file.

python script.py >> logfile.txt 2>&1

Upon return, I find that I have been automatically logged out and the job doesn't finish. Furthermore, there is no evidence of a bug in the log file. It seems that the user process is being killed, and I'm curious how to catch it and then to prevent it from happening.

Further relevant detail is that the python script is executing many database operations on a fairly large mongodb instance (~4million rows).

I suspect that this has something to do with the ulimit settings. Mine are as follows:

$ ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
file size               (blocks, -f) unlimited
max locked memory       (kbytes, -l) unlimited
max memory size         (kbytes, -m) unlimited
open files                      (-n) 256
pipe size            (512 bytes, -p) 1
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 709
virtual memory          (kbytes, -v) unlimited
  • Are you getting logged out of a normal session on the Mac console, or an ssh session between the Mac and some other system? – Mark Plotnick Mar 29 '15 at 0:11
  • @MarkPlotnick Both, actually. First a normal session, and I also tried via ssh with nohup. – sinwav Mar 29 '15 at 9:36
  • Can you check if the Mac is actually crashing and rebooting? Are there any system log messages about running low on swap space? – Mark Plotnick Mar 30 '15 at 1:10
  • @MarkPlotnick Ooh, I didn't think of that. I don't have anyway to check now, but in retrospect it could well have been a reboot. And I did find some system logs about running low on swap space and killing of processes. kernel[0]: low swap: suspending pid 3640 (Terminal), kernel[0]: low swap: killing pid 3700 (mdworker), kernel[0]: low swap: unable to find any eligible processes to take action on. Sounds like we know what's happening now. The question becomes, how to address this? – sinwav Mar 30 '15 at 18:43
  • Adding more swap space on a Mac should be straightforward, but I don't know offhand how to do it in Yosemite. – Mark Plotnick Apr 3 '15 at 15:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.