nohup

How bash handles the jobs when logout?

情到浓时终转凉″ 提交于 2019-11-30 12:03:05
问题 As far as I understood from the books and bash manuals is that. When a user logs out from bash all the background jobs that is started by the user will automatically terminate, if he is not using nohup or disown. But today I tested it : Logged in to my gnome desktop and accessed gnome-terminal. There are two tabs in the terminal and in one I created a new user called test and logged in as test su - test started a script. cat test.sh #!/bin/bash sleep 60 printf "hello world!!" exit 0 ./test.sh

linux后台执行程序相关命令

六月ゝ 毕业季﹏ 提交于 2019-11-30 10:30:27
linux下我们如果想一个任务或者程序还后台执行可以使用&,实际上linux还提供了其他任务调度的命令。 bg 将一个在后台暂停的命令,变成继续执行 fg 将后台中的命令调至前台继续运行 jobs 查看当前有多少在后台运行的命令 ctrl + z 可以将一个正在前台执行的命令放到后台,并且暂停 nohup 命令 用途:不挂断地运行命令。 语法:nohup Command [ Arg … ] [ & ] 描述:nohup 命令运行由 Command 参数和任何相关的 Arg 参数指定的命令,忽略所有挂断(SIGHUP)信号。在注销后使用 nohup 命令运行后台中的程序。要运行后台中的 nohup 命令,添加 & ( 表示”and”的符号)到命令的尾部 来看实际操作的例子 启动一个时钟程序: ctrl+z以后输出为: 这个使用用pidof xclock去查看进程号还是存在,说明程序在后台暂停 执行bg %1 可以看到程序继续执行 一个更明显的例子可以看出bg和fg的区别:firefox &符号有无的区别 nohup 如果你正在运行一个进程,而且你觉得在退出帐户时该进程还不会结束,那么可以使用nohup命令。该命令可以在你退出帐户之后继续运行相应的进程。nohup就是不挂起的意思( no hang up)。 该命令的一般形式为: nohup conmmand &

nohup vs screen — which is better for long running process?

北战南征 提交于 2019-11-30 04:51:57
Background: I have a long running script that makes database schema changes that has output I would want to check after the migration. I would want to write this to a file. I have been reading stack overflow about nohup and screen. I have tried both and have concerns about both. IN: How to run process as background and never die? They said they used nohup and putty killed the process. How is this possible? I have been unable to replicate using Mac OS X terminal. With screen I am terrified of typing exit instead of ctrl + a, d Also If I just quit the terminal app when using screen, it seems to

Django部署:Django+gunicorn+Nginx环境的搭建

白昼怎懂夜的黑 提交于 2019-11-30 01:45:53
本人的服务器环境为Ubuntu14.04,使用的是Python3.4版本,并且安装有pip(Ubuntu中Python3配合的是pip3),并且以管理员身份运行,如果是普通用户,请切换管理员权限(sudo)。 一.gunicorn和nginx的简介 gunicorn需要搭配nginx使用,那么两者的作用到底是什么。 1.gunicorn简介:gunicorn是一个Python WSGI UNIX服务器。WSGI(Web Server Gateway Interface)是Web服务网关接口,位于WEB应用层和WEB服务器层之间。在这里WEB应用当然是指Python解释器及Django编写的程序,而WEB服务器指的是Nginx,所以Gunicorn位于两者之间。 2.Nginx简介:Nginx是反向代理服务器,接收外部Internet网络请求,并将请求转发给内部网络的WSGI,并将响应信息反馈给外部Internet用户。所以gunicorn就是起到沟通作用,将Django和Nginx联系起来,也就是我们说的网关作用。 二.Django,Gunicorn,Nginx的安装 在这里我们使用的是Django最新版本1.8.4,当然,你也可以选择其他版本。 #pip3 install Django==1.8.4 #pip3 install gunicorn #apt-get install

how to run a command in background using ssh and detach the session

Deadly 提交于 2019-11-29 20:29:20
I'm currently trying to ssh into a remote machine and run a script, then leave the node with the script running. Below is my script. However, when it runs, the script is successfully run on the machine but ssh session hangs. What's the problem? ssh -x $username@$node 'rm -rf statuslist mkdir statuslist chmod u+x ~/monitor/concat.sh chmod u+x ~/monitor/script.sh nohup ./monitor/concat.sh & exit;' There are some situations when you want to execute/start some scripts on a remote machine/server (which will terminate automatically) and disconnect from the server. eg: A script running on a box which

How to kill a nohup process?

孤街醉人 提交于 2019-11-29 19:52:44
I executed the following command $ nohup ./tests.run.pl 0 & now when I try to kill it (and the executions that are started from this script) using $ kill -0 <process_id> it does not work. How can I kill a nohupped process and the processes that runs via the nohupped script? Thanks kill -0 does not kill the process. It just checks if you could send a signal to it. Simply kill pid , and if that doesn't work, try kill -9 pid . Simply kill <pid> which will send a SIGTERM , which nohup won't ignore. You should not send a SIGKILL first as that gives the process no chance to recover; you should try

使用screen代替nohup

谁说胖子不能爱 提交于 2019-11-29 19:35:07
使用nohup的问题及原因 详见这里 使用screen代替nohup 安装 yum install -y screen 进入screen独立终端 screen命令无需root权限即可执行。 screen 或者 screen < command > 在screen独立终端内拥有完整的bash环境,可以随意执行后台命令。 比如 ./a_service 或者 ./a_daemon & 退出screen独立终端 按 ctrl + a ,再按 d 键 退出时会显示screen终端进程ID: ---------------------------------------------- [ detached from 78898.pts-0.localhost ] 这里的78898为screen终端进程ID。 查看screen的终端进程ID [ user@localhost ~ ] $ screen -ls There is a screen on: 78898.pts-0.localhost ( Detached ) 1 Socket in /var/run/screen/S-user. 这里的78898为screen终端进程ID。 恢复screen终端 screen -r 78898 将再次进入之前的screen独立终端中,且会发现前边运行的进程没有退出,还在继续执行。 [ user

Linux后台运行java的jar包

拟墨画扇 提交于 2019-11-29 19:34:40
前言 需要执行的jar为:sysrd-test.jar,并已经上传到了Linux服务器上! 直接运行方式 java -jar sysrd-test.jar 通过这种方式部署的时候,SecureCRT的shell是被锁定的,我们无法再执行其他的操作,如下: [root@48 opt]# java -jar sysrd-test.jar . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v1.4.4.RELEASE) 2017-05-25 14:13:27.909 INFO 29120 --- [ main] c.t.srd.tcldp.SrdTcldpApplication : Starting SrdTcldpApplication v0.0.1-SNAPSHOT on 48.sysrd with PID 29120 (/opt/sysrd-test.jar

Linux中jar包 后台运行方式

喜欢而已 提交于 2019-11-29 19:33:37
Linux 运行jar包命令如下: 方式一: java -jar Sub-Sign-0.0.1-SNAPSHOT.jar 特点:当前ssh窗口被锁定,可按CTRL + C打断程序运行,或直接关闭窗口,程序退出 那如何让窗口不锁定? 方式二: java -jar Sub-Sign-0.0.1-SNAPSHOT.jar & &代表在后台运行。 特点:当前ssh窗口不被锁定,但是当窗口关闭时,程序中止运行。 继续改进,如何让窗口关闭时,程序仍然运行? 方式三: nohup java -jar Sub-Sign-0.0.1-SNAPSHOT.jar & nohup 意思是不挂断运行命令,当账户退出或终端关闭时,程序仍然运行 当用 nohup 命令执行作业时,缺省情况下该作业的所有输出被重定向到nohup.out的文件中,除非另外指定了输出文件。 方式四: nohup java -jar Sub-Sign-0.0.1-SNAPSHOT.jar >temp.txt & 解释下 >temp.txt command >out.file command >out.file是将command的输出重定向到out.file文件,即输出内容不打印到屏幕上,而是输出到out.file文件中。 可通过jobs命令查看后台运行任务 jobs 那么就会列出所有后台执行的作业,并且每个作业前面都有个编号。

运行 jar

主宰稳场 提交于 2019-11-29 19:00:57
rz rm -rf incoHive.jar >>spark-submit --queue=mr --class com.inco.hive.CNlawTOxml.Lge_SparkRead --master yarn --num-executors 10 --executor-memory 10g --total-executor-cores 100 --jars /opt/exlib/source-1.0.jar /home/liyingying/incoHive.jar >>nohup spark-submit --queue=mr --class com.inco.hive.CNlawTOxml.Lge_SparkRead --master yarn --num-executors 10 --executor-memory 10g --total-executor-cores 100 --jars /opt/exlib/source-1.0.jar /home/liyingying/incoHive.jar & --2.11 >>nohup spark-submit --queue=mr --class com.inco.hive.CNlawTOxml.Lge_ReadNew --master yarn --num-executors 10 --executor