nohup

linux的nohup命令的用法

南笙酒味 提交于 2019-12-03 20:01:42
在应用Unix/Linux时,我们一般想让某个程序在后台运行,于是我们将常会用 & 在程序结尾来让程序自动运行。比如我们要运行mysql在后台: /usr/local/mysql/bin/mysqld_safe –user=mysql &。可是有很多程序并不想mysqld一样,这样我们就需要nohup命令,怎样使用nohup命令呢?这里讲解nohup命令的一些用法。 nohup /root/start.sh & 在shell中回车后提示: [~]$ appending output to nohup.out 原程序的的标准输出被自动改向到当前目录下的nohup.out文件,起到了log的作用。 但是有时候在这一步会有问题,当把终端关闭后,进程会自动被关闭,察看nohup.out可以看到在关闭终端瞬间服务自动关闭。 咨询红旗Linux工程师后,他也不得其解,在我的终端上执行后,他启动的进程竟然在关闭终端后依然运行。 在第二遍给我演示时,我才发现我和他操作终端时的一个细节不同:他是在当shell中提示了nohup成功后还需要按终端上键盘任意键退回到shell输入命令窗口,然后通过在shell中输入exit来退出终端;而我是每次在nohup执行成功后直接点关闭程序按钮关闭终端.。所以这时候会断掉该命令所对应的session,导致nohup对应的进程被通知需要一起shutdown。

远程访问阿里云服务器jupyter

烂漫一生 提交于 2019-12-03 16:53:51
官网链接 一、pip安装jupyter 安装Anaconda的话,会自动按照jupyter,就不需要再使用pip安装了 pip3 install jupyter 二、生成jupyter notebook配置文件 jupyter notebook --generate-config 记住生成配置文件的目录,一般是在/root/.jupyter 中 三、设置Jupyter登陆密码,生成对应密文 ipython #打开ipython from notebook.auth import passwd passwd() #复制生成的密文 设置浏览器Jupyter登录密码 Enter password: #输入密码 Verify password: #确认密码 四、修改配置文件 配置文件在当前用户默认根目录的 .jupyter 文件夹下,例如: /home/zql vi ~/.jupyter/jupyter_notebook_config.py 插入如下代码,粘贴刚刚生成的密文 c.NotebookApp.ip='*' c.NotebookApp.password = u'sha1:...刚才复制的那个密文' c.NotebookApp.open_browser = False c.NotebookApp.port =8888 c.NotebookApp.allow_remote_access

nohup as background task does NOT return prompt

删除回忆录丶 提交于 2019-12-03 16:32:31
问题 I am trying to run a long running task in the background without having to be logged in and have the terminal return a prompt, but when I do this, the task appears to go into the background, but my prompt does not become available unless I hit control + c. I want to run the task and then get my prompt back. [staging@php-pos-web ~]$ nohup php test.php > test.txt & [1] 27251 [staging@php-pos-web ~]$ nohup: ignoring input and redirecting stderr to stdout 回答1: You should have your prompt

nohup sh start.sh >/dev/null 2>&1 &

走远了吗. 提交于 2019-12-03 15:42:20
nohup sh start.sh >/dev/null 2>&1 & 背景说明 start.sh 脚本里,写了Java应用程序启动的相关命令,并且在 log4j.properties 中配置了日志的输出路径。 此时,启动服务的时候,如果使用如下命令,则会在start.sh脚本所在的目录下,产生一个名为 nohup.out 的输出文件。 nohup sh start.sh & 这个多余的 nohup.out 文件是不需要的,可以使用如下命令解决: nohup sh start.sh >/dev/null 2>&1 & 命令解析 1、nohup & nohup 表示 永久运行 , & 表示 后台运行 。 2、>/dev/null 2>&1 /dev/null 代表 空设备文件 ,也就是不输出任何信息到终端。 操作系统中有三个常用的流:   0:标准输入流 stdin   1:标准输出流 stdout   2:标准错误流 stderr " >/dev/null " 等价于 " 1>/dev/null ",表示 标准输出 (1)输出到 /dev/null 中,即 终端不输出标准输出信息 ; " 2>&1 " 中的 “ & ” 是 等价于 的意思,表示 标准错误 (2)输出的位置 等价于 标准输出 (1)的位置,即等价于 “ 2>/dev/null ”, 即 终端不输出标准错误信息 。

Get the PID of a process started with nohup via ssh

二次信任 提交于 2019-12-03 12:52:48
问题 I want to start a process using nohup on a remote machine via ssh. The problem is how to get the PID of the process started with nohup, so the "process actually doing something", not some outer shell instance or the like. Also, I want to store stdout and stderr in files, but that is not the issue here... Locally, it works flawlessly using nohup sleep 30 > out 2> err < /dev/null & echo $! It is echoing me the exact PID of the command "sleep 30", which I can also see using "top" or "ps aux|grep

Unable to start service with nohup due to 'INFO spawnerr: unknown error making dispatchers for 'app_name': EACCES'

你离开我真会死。 提交于 2019-12-03 12:49:39
I'm trying to start a service with supervisor, but I get an error saying INFO spawnerr: unknown error making dispatchers for 'app_name': EACCES Here's my supervisord.conf file: [supervisord] logfile=/tmp/supervisord.log logfile_maxbytes=50MB ; change these depending on how many logs logfile_backups=10 ; you want to keep loglevel=info pidfile=/tmp/supervisord.pid nodaemon=true minfds=1024 minprocs=200 [rpcinterface:supervisor] supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface [supervisorctl] serverurl=unix:///tmp/supervisor.sock socket [program:myscript] command=

每天一个linux命令:tail(16)

谁都会走 提交于 2019-12-03 11:53:30
tail tail 命令用于输入文件中的尾部内容,不指定文件时,作为输入信息进行处理。tail命令默认在屏幕上显示指定文件的末尾10行。命令从指定点开始将文件写到标准输出,使用tail命令的 -f 选项可以方便的查阅正在改变的日志文件, tail -f filename 会把文件里最尾部的内容显示在屏幕上,并且不但刷新,使你看到最新的文件内容 ,常用于查看日志 。常用查看日志文件。 格式 tail [参数] [文件] ​ 参数选项 参数 备注 -f 显示文件最新追加的内容,循环读取 -q 不显示处理信息,当有多个文件参数时,不输出各个文件名 -v 显示详细的处理信息,当有多个文件参数时,总是输出各个文件名 -c 显示的字节数 -n 显示行数 --pid 与-f合用,表示在进程ID,PID死掉之后结束 -s, -s或--sleep-interal=<秒数 常与“-f”选项连用,指定监视文件变化时间隔的秒数 实例 显示文件末尾内容 命令: tail -n 5 myFile [root@VM_0_9_centos ~]# cat myFile this is line 1; this is line 2; this is line 3; tihs is line 4; this is line 5; this is line 6; this is line 7; this is line

111

核能气质少年 提交于 2019-12-03 10:43:30
https://blog.csdn.net/u014203449/article/details/79968477 https://www.cnblogs.com/juandx/p/4839054.html 在linux服务器上运行Jar文件时通常的方法是: $ java -jar test.jar 1 这种方式特点是ssh窗口关闭时,程序中止运行.或者是运行时没法切出去执行其他任务,有没有办法让Jar在后台运行呢: 方法一: $ nohup java -jar test.jar & //nohup 意思是不挂断运行命令,当账户退出或终端关闭时,程序仍然运行 //当用 nohup 命令执行作业时,缺省情况下该作业的所有输出被重定向到nohup.out的文件中 //除非另外指定了输出文件。 1 2 3 4 5 方法二: $ nohup java -jar test.jar >temp.txt & //这种方法会把日志文件输入到你指定的文件中,没有则会自动创建 1 2 3 jobs命令和 fg命令: $ jobs //那么就会列出所有后台执行的作业,并且每个作业前面都有个编号。 //如果想将某个作业调回前台控制,只需要 fg + 编号即可。 $ fg 2 1 2 3 4 查看某端口占用的线程的pid netstat -nlp |grep :8080 来源: https://www

phantomjs with nohup not working

匿名 (未验证) 提交于 2019-12-03 08:30:34
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I was trying to run phantomjs script via ssh using nohup command . But nohup threw an error which i found in nohup.out file. My command was --> nohup phantomjs example.js & phantomjs example.js run perfectly without nohup . I have also created a bash script to run this command with nohup but both time, I got this error --> events.js:72 throw er; // Unhandled 'error' event ^ Error: EBADF, read ** code of example.js var page = require('webpage').create(), system = require('system'), address, output, size; if (system.args.length < 3 || system

Get the PID of a process started with nohup via ssh

自古美人都是妖i 提交于 2019-12-03 03:12:46
I want to start a process using nohup on a remote machine via ssh. The problem is how to get the PID of the process started with nohup, so the "process actually doing something", not some outer shell instance or the like. Also, I want to store stdout and stderr in files, but that is not the issue here... Locally, it works flawlessly using nohup sleep 30 > out 2> err < /dev/null & echo $! It is echoing me the exact PID of the command "sleep 30", which I can also see using "top" or "ps aux|grep sleep". But I'm having trouble doing it remotely via ssh. I tried something like ssh remote_machine