nohup

linux命令后台运行

徘徊边缘 提交于 2019-11-28 05:07:39
有两种方式: 1. command & : 后台运行,你关掉终端会停止运行 2. nohup command & : 后台运行,你关掉终端也会继续运行 一、 简介 Linux/Unix 区别于微软平台最大的优点就是真正的多用户,多任务。因此在任务管理上也有别具特色的管理思想。 我们知道,在 Windows 上面,我们要么让一个程序作为服务在后台一直运行,要么停止这个服务。而不能让程序在前台后台之间切换。而 Linux 提供了 fg 和bg 命令,让你轻松调度正在运行的任务。假设你发现前台运行的一个程序需要很长的时间,但是需要干其他的事情,你就可以用 Ctrl-Z ,挂起这个程序,然后可以看到系统提示: [1]+ Stopped /root/bin/rsync.sh 然后我们可以把程序调度到后台执行:(bg 后面的数字为作业号) #bg 1 [1]+ /root/bin/rsync.sh & 用 jobs 命令查看正在运行的任务: #jobs [1]+ Running /root/bin/rsync.sh & 如果想把它调回到前台运行,可以用 #fg 1 /root/bin/rsync.sh 这样,你在控制台上就只能等待这个任务完成了。 & 将指令丢到后台中去执行 [ctrl]+z 將前台任务丟到后台中暂停 jobs 查看后台的工作状态 fg %jobnumber

Nohup is not writing log to output file

强颜欢笑 提交于 2019-11-28 02:54:32
I am using the following command to run a python script in the background: nohup ./cmd.py > cmd.log & But it appears that nohup is not writing anything to the log file. cmd.log is created but is always empty. In the python script, I am using sys.stdout.write instead of print to print to standard output. Am I doing anything wrong? It looks like you need to flush stdout periodically (e.g. sys.stdout.flush() ). In my testing Python doesn't automatically do this even with print until the program exits. You can run Python with the -u flag to avoid output buffering: nohup python -u ./cmd.py > cmd

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

别说谁变了你拦得住时间么 提交于 2019-11-28 02:04:48
问题 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

ubutun18.04安装 rocketmq

你说的曾经没有我的故事 提交于 2019-11-28 00:02:56
1、安装 rocketmq首先要有java以及maven环境,这里略过,可参考 https://www.cnblogs.com/xiaobaoTribe/p/11315011.html 安装JDK 1.8 https://www.cnblogs.com/xiaobaoTribe/p/11361881.html 安装maven 3.5.1 2、切换目录 root@ubuntu:~$ cd /usr/local 3、按照官网指示,下载源文件 rocketmq-all-4.4.0-source-release.zip , 下载页 http://rocketmq.apache.org/dowloading/releases/ root@ubuntu:/usr/local$ wget h ttp://mirrors.tuna.tsinghua.edu.cn/apache/rocketmq/4.4.0/rocketmq-all-4.4.0-source-release.zip 4、解压文件 root@ubuntu:/usr/local$ unzip rocketmq-all-4.4.0-source-release.zip 5、删除文件 root@ubuntu:/usr/local$ remove rocketmq-all-4.4.0-source-release.zip 6、编译打包程序

jiacrontab 2.0.*

…衆ロ難τιáo~ 提交于 2019-11-27 23:59:14
简单可信赖的任务管理工具 v2.0.0版发布 ❤jiacrontab 最新版下载点这里❤ 1.自定义job执行 2.允许设置job的最大并发数 3.每个脚本都可在web界面下灵活配置,如测试脚本运行,查看日志,强杀进程,停止定时… 4.允许添加脚本依赖(支持跨服务器),依赖脚本提供同步和异步的执行模式 5.支持异常通知 6.支持守护脚本进程 7.支持节点分组 架构 说明 jiacrontab 由 jiacrontab_admin,jiacrontabd 两部分构成,两者完全独立通过 rpc 通信 jiacrontab_admin:管理后台向用户提供web操作界面 jiacrontabd:负责job数据存储,任务调度 安装 二进制安装 1. 下载 二进制文件。 2.解压缩进入目录(jiarontab_admin,jiacrontabd)。 3.运行 $ nohup ./jiacrontab_admin &> jiacrontab_admin.log & $ nohup ./jiacrontabd &> jiacrontabd.log & v2.0.x源码安装 1.安装 git,golang(version 1.12.x);可参考官网。 2.安装运行 $ cd $GOPATH/src $ git clone git@github.com:iwannay/jiacrontab.git $

How to include nohup inside a bash script?

烈酒焚心 提交于 2019-11-27 23:00:49
I have a large script called mandacalc which I want to always run with the nohup command. If I call it from the command line as: nohup mandacalc & everything runs swiftly. But, if I try to include nohup inside my command, so I don't need to type it everytime I execute it, I get an error message. So far I tried these options: nohup ( command1 .... commandn exit 0 ) and also: nohup bash -c " command1 .... commandn exit 0 " # and also with single quotes. So far I only get error messages complaining about the implementation of the nohup command, or about other quotes used inside the script. cheers

nohup: run PHP process in background

余生长醉 提交于 2019-11-27 18:19:43
问题 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

Why can't I use Unix Nohup with Bash For-loop?

时光怂恿深爱的人放手 提交于 2019-11-27 07:59:37
For example this line fails: $ nohup for i in mydir/*.fasta; do ./myscript.sh "$i"; done > output.txt& -bash: syntax error near unexpected token `do What's the right way to do it? Because 'nohup' expects a single-word command and its arguments - not a shell loop construct. You'd have to use: nohup sh -c 'for i in mydir/*.fasta; do ./myscript.sh "$i"; done >output.txt' & You can do it on one line, but you might want to do it tomorrow too. $ cat loopy.sh #!/bin/sh # a line of text describing what this task does for i in mydir/*.fast ; do ./myscript.sh "$i" done > output.txt $ chmod +x loopy.sh $

nohup 命令 - 将程序以忽略挂起信号的方式运行起来

橙三吉。 提交于 2019-11-27 07:12:34
使用场景:一般我们都会使用 XShell 等终端模拟软件连接 Linux 服务器,但是在运行比较长时间的脚本(特别是一些 HiveQL 脚本)的时候,往往都要跑上个把小时甚至更长,这期间如果关闭终端窗口,运行的进程就会被杀死。使用 nohup 命令可以使进程不受终端窗口的影响。 1 使用实例 使用 nohup 命令提交作业,在缺省情况下该作业的所有输出都被重定向到一个名为 nohup.out 的文件中(默认在当前目录下,如果文件不可写,输出重定向到 $HOME/nohup.out 文件中),除非另外指定了输出文件: nohup command > myout.file 2>&1 & 之后可以使用命令 tail -f myout.file 实时查看 command 的运行情况。 2 为什么nohup命令最后要加个 & 呢 这里要说明下 nohup 与 & 的功能区别: & 的意思是在后台运行,用 Ctrl+C 无法杀死后台进程。但是如果 XShell 关闭的话,后台进程同样会被杀死。 相反,如果 nohup 最后不加 & ,使用 Ctrl+C 是可以杀死 command 的。所以要让进程真正不受 XShell 中 Ctrl+C 和关闭终端窗口的影响,需要二者组合使用。 3 参考文章 http://man.linuxde.net/nohup https://blog.csdn.net

Call a function using nohup

为君一笑 提交于 2019-11-27 06:38:00
问题 I am trying to call a function using nohup like this: function1(){ while true do echo "function1" sleep 1 done } nohup function1 & # ...... some other code but may be the function isn't seen by nohup and I get this error: nohup: failed to run command `function1' : No such file or dictionary I don't want to create new sh file for my function. How can I fix this? 回答1: Another solution: function background { echo TEST } export -f background nohup bash -c background & 回答2: nohup applies to