linux nohup

If standard output is a terminal, append output to 'nohup.out'

If standard error is a terminal, redirect it to standard output.  To save output to FILE, use 'nohup COMMAND > FILE'.


nohup: ignoring input and appending output to `nohup.out'




nohup sh test.sh &


�Ὣ�ű��е����(��׼����ʹ������)��append����·���µ�nohup.out�ļ���


���ʹ��nohup�����ύ��ҵ����ô��ȱʡ����¸���ҵ��������������ض���һ����Ϊnohup.out���ļ��У��������ָ��������ļ���


nohup command > myout.file 2>&1 &


Ӧ��: 

1 �Ҳ���Ҫ���ű��еĴ������д��nohup�ļ���

nohup sh test.sh 2>/dev/null &


2 ����Ҫ���ű��е���������һ���ļ��ж���nohup.out��




����������˳����նˣ�����ps -ef |grep "test.sh"��ʱ��������ʾ���ض����ĸ��ļ������ʱ������ҳ��أ�


����

��һ��:

ps -ef |grep "test.sh"   �ҳ������̵�pid


[root@master scripts]# ps -ef |grep "test.sh"

root      2700     1  0 20:38 ?        00:00:00 sh test.sh


�ڶ���: ����lsof�г���������ռ�õ��ļ�

lsof -p 2700




ע�⣺ nohup python test.py & ����tail -f nohup.out �õ��Ľ��������Ҫ�ã������Ҫ���python�е�(print ���� sys.stdout.write() sys.stdout.flush()) ���������һ���ˡ��и�����ĸ��



���ij��� ���޵»���ά��ҵ·�� ���ͣ�����ر����˳���http://cuidehua.blog.51cto.com/5449828/1812430

你可能感兴趣的:(linux nohup)