nohup

Monit bundle exec rails s

安稳与你 提交于 2019-11-29 17:18:14
I have the following shell script that allows me to start my rails app, let's say it's called start-app.sh : #!/bin/bash cd /var/www/project/current . /home/user/.rvm/environments/ruby-2.3.3 RAILS_SERVE_STATIC_FILES=true RAILS_ENV=production nohup bundle exec rails s -e production -p 4445 > /var/www/project/log/production.log 2>&1 & the file above have permissions of: -rwxr-xr-x 1 user user 410 Mar 21 10:00 start-app.sh* if i want to check the process I do the following: ps aux | grep -v grep | grep ":4445" it'd give me the following output: user 2960 0.0 7.0 975160 144408 ? Sl 10:37 0:07 puma

Linux执行后台work相关

走远了吗. 提交于 2019-11-29 16:27:31
Linux的后台运行、关闭、查看后台任务 & ctrl+z jobs fg bg kill nohup setsid disown screen 1.& 加在命令的最后,可以把命令放到后台执行: watch -n 10 sh test.sh #每10s后台执行一次test.sh脚本 2.ctrl+z 可以将一个在前台运行的命令放到后台,且处于暂停状态 3.jobs 查看当前有所少在后台运行的命令 jobs -l选项可显示所有任务的PID,jobs的状态可以是running、stopped、terminated。 但是如果任务被终止了(kill),shell从当前的shell环境已知的列表中删除任务的进程标识 jobs命令选项 -l 列出进程ID及其他信息 -p 仅列出进程ID -n 仅列出自从上次输出状态变化提示后的发生了状态变化的进程 -r 仅显示运行中的作业 -s 仅显示停止的作业 -x 运行命令及其参数,并用新的命令的进程ID替代所匹配的原有作业的进程组ID 4.fg 将后台中命令调至前台继续运行,如果后台有多个命令,可以用fg %jobnumber(是命令编号,不是进程号)将选中的命令调出 # jobs -l [2] - stopped .... [3] + stopped ... # fg 2 5.bg 将一个后台暂停的命令,变成后台继续运行,如果后台有多个命令

Linux命令记录

雨燕双飞 提交于 2019-11-29 15:41:33
目录 通过进程名查看其占用端口 查看进程 关闭进程 端口 查看进程占用CPU、内存 重启主机 查看和添加环境变量 解压缩 文件操作 Nginx Jenkins 构建通过shell无法启动进程问题 后台运行java的jar包 Zookeeper 切换用户 Elasticsearch Elastichsearch-head 终端控制键 MongoDB 看磁盘内存 Redis Tomcat 进程后台运行 通过进程名查看其占用端口 1、 先查看进程pid ps -ef | grep 进程名 2、 通过pid查看占用端口 netstat -nap | grep 进程pid 查看进程 ps 参数 -A -ef -aux //显示所有状态 查找nginx相关进程: ps -ef |grep nginx 关闭进程 杀死进程最安全的方法是单纯使用kill命令,不加修饰符,不带标志。 首先使用ps -ef命令确定要杀死进程的PID,然后输入以下命令: kill -pid 注释:标准的kill命令通常都能达到目的。终止有问题的进程,并把进程的资源释放给系统。然而,如果进程启动了子进程,只杀死父进程,子进程仍在运行,因此仍消耗资源。为了防止这些所谓的“僵尸进程”,应确保在杀死父进程之前,先杀死其所有的子进程。 确定要杀死进程的PID或PPID ps -ef | grep httpd 以优雅的方式结束进程

linux命令后台运行

前提是你 提交于 2019-11-29 12:40:45
来源: http://www.php100.com/html/webkaifa/Linux/2010/0718/6376.html 1.在下达的命令后面加上&,就可以使该命令在后台进行工作,这样做最大的好处就是不怕被ctrl+c这个中断指令所中断。   2. 那大家可能又要问了,在后台执行的程序怎么使它恢复到前台来运行呢?很简单,只用执行fg这个命令,就可以了。   3.可能有些同学又要问了,我现在已经在前台运行的命令,我能把它放到后台去运行么?当然可以了,只要执行ctrl+z就可以做到了。是不是很赞啊!   4.说到这里可能有些同学又要问了,如果我有多个进程在后台运行,那如何恢复到前台来执行呢?这时候就要用到jobs这个命令了,通过jobs这个命令,能够列出所有在后台执行的进程,那个中括号([ ])里面的数字就是 jobs 的代号啰 ,通过fg %number 就可以恢复指定的后台进程.   使用nohup让程序在远程主机后台运行   因为我购买的一个国外主机居然开放了Telnet权限,因此我也使用Telnet登录上去玩玩Linux,但发现一关闭窗口就自动和主机断开了,和的终端不一样,所以就上网找啊找,找到了一个从后台一直运行某个程序的方法。   Unix/Linux下一般比如想让某个程序在后台运行,很多都是使用 & 在程序结尾来让程序自动运行。比如我们要运行mysql在后台:

Nohup and Python -u : it still doesn't log data in realtime

与世无争的帅哥 提交于 2019-11-29 11:03:20
When launching a Python process, in background, with nohup python myscript.py > test.log 2>&1 < /dev/null & the problem is that stdout is buffered: the data is not written in realtime to test.log . The common solution to this problem is to flush periodically with sys.stdout.flush() , or even better, as suggested by this answer , to use python -u : nohup python -u myscript.py > test.log 2>&1 < /dev/null & But this is not enough . I noticed that it worked during a few hours, and then, it stopped working, i.e. after a few hours test.log is not written in realtime anymore, even if I used nohup

nohup 命令

坚强是说给别人听的谎言 提交于 2019-11-29 10:27:52
nohup command > myout.file 2>&1 & 指定nohup.out的文件名 jobs -l 查看后台命令 来源: https://www.cnblogs.com/liuzz-20180701/p/11515419.html

jsch ChannelExec run a .sh script with nohup “lose” some commands

强颜欢笑 提交于 2019-11-29 08:28:51
I hava a .sh script which glues many other scripts, called by jsch ChannelExec from a windows application. Channel channel = session.openChannel("exec"); ((ChannelExec) channel).setCommand("/foo/bar/foobar.sh"); channel.connect(); if I run the command like "nohup /foo/bar/foobar.sh >> /path/to/foo.log &", all the long term jobs(database operations, file processing etc.) seems to get lost. checking the log file, only find those echo stuffs(before and after a long term operation, calculate running time etc.). I checked the permissions, $PATH, add source /etc/profile to my .sh yet none of these

nohup: run PHP process in background

余生颓废 提交于 2019-11-29 04:29:53
i try to run php processes in background and start this from an php file. Some informations: PHP Version 5.2.17, php safe_mode is off, linux system. I start the process with exec, tried already shell_exec. I set all files to 0755, 0777. $pid = exec("nohup $cmd > /dev/null 2> /dev/null & echo $!"); If i print this statement, i get this and the pid is okay: nohup /usr/local/bin/php5 /.../../file.php > /dev/null 2> /dev/null & echo $! If i look for processes under ssh with top i see my php5 process with the correct pid. user is root PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 3533

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

喜你入骨 提交于 2019-11-29 02:21:45
问题 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