簡體   English   中英

nohup命令僅在相對目錄中有效

[英]nohup command only works in relative directory

我試圖通過nohup運行python腳本,並調出它的完整路徑不會拋出no such file or directory

例子:

nohup python3 ./script.py

作品

nohup python3 /full/path/to/file/script.py

不起作用。

cat nohup.out

Python: can't open file '/full/path/to/file/script.py':
[Errno 2] No such file or directory

如果我給它完整的路徑,為什么nohup找不到文件,但是如果我在目錄中,為什么找不到它?

它也可以在絕對路徑下工作。 下面是一個示例。

我正在通過python腳本同時使用絕對路徑和相對路徑來打印Linux服務器時間。

[root@ip-172-31-11-214 tmp]# pwd
/tmp
[root@ip-172-31-11-214 tmp]# ls -lrth
total 4.0K
-rw-rw-r-- 1 ec2-user ec2-user 113 Aug  9 20:28 test.py
[root@ip-172-31-11-214 tmp]# nohup python test.py
nohup: ignoring input and appending output to ‘nohup.out’
[root@ip-172-31-11-214 tmp]# cat nohup.out
This line will be printed.
2019-08-09 20:29:37.417722
[root@ip-172-31-11-214 tmp]# cd /root/
[root@ip-172-31-11-214 ~]# pwd
/root
[root@ip-172-31-11-214 ~]# nohup python /tmp/test.py
nohup: ignoring input and appending output to ‘nohup.out’
[root@ip-172-31-11-214 ~]# cat /root/nohup.out
This line will be printed.
2019-08-09 20:30:26.057960
[root@ip-172-31-11-214 ~]#

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM