nohup

Linux后台执行脚本文件,nohup

风格不统一 提交于 2019-12-23 16:00:18
看运维人员执行nohup命令后,把程序放在后台执行,很高大上,就研究了一下,这个命令. nohup命令及其输出文件 nohup命令:如果你正在运行一个进程,而且你觉得在退出帐户时该进程还不会结束,那么可以使用nohup命令。该命令可以在你退出帐户/关闭终端之后继续运行相应的进程。nohup就是不挂起的意思( n ohang up)。 该命令的一般形式为:nohup command &   使用nohup命令提交作业   如果使用nohup命令提交作业,那么在缺省情况下该作业的所有输出都被重定向到一个名为nohup.out的文件中,除非另外指定了输出文件:    nohup command > myout.file 2>&1 &   在上面的例子中,输出被重定向到myout.file文件中。   使用 jobs 查看任务。 例子: nohup php activity_insert_user.php 61 26_02.txt > 26_02.log 2>&1 & 注意事项: 2>&1 是一个整体,中间没有空格,表示把标准输出和错误输出都传到指定文件中. 下面是详解: ls xxx 1>out.txt 2>&1 nohup /mnt/Nand3/H2000G >/ dev / null 2>&1 & 对 于& 1 更准确的说应该是文件描述符 1,而1 一般代表的就是STDOUT

Running a script from a script in android

二次信任 提交于 2019-12-23 02:55:09
问题 i am trying to use an init.d script to execute another script in the background. The init.d script must continue immediatly after executing the other script in the background so my device can boot completely and then the executed script can do its commands. I have googled and found that the & symbol can be used at the end of the script name to execute it in the background. This worked, but my init.d script waited until the background script was finished. So i googled some more, and found that

Linux scp 设置nohup后台运行

…衆ロ難τιáo~ 提交于 2019-12-22 11:33:58
1.正常执行scp命令 2.输入ctrl + z 暂停任务 3.bg将其放入后台 4.disown -h 将这个作业忽略HUP信号 5.测试会话中断,任务继续运行不受影响 1.正常执行scp命令 从oradb30机器拷贝一个文件夹到oradb31机器: scp -r /u01/media/Disk1/ 192.168.1.31:/u01/media/ [root@oradb30 ~]# scp -r /u01/media/Disk1/ 192.168.1.31:/u01/media/ reverse mapping checking getaddrinfo for bogon failed - POSSIBLE BREAK-IN ATTEMPT! root@192.168.1.31's password: ... filegroup2.jar 100% 84KB 83.8KB/s 00:00 filegroup9.jar 100% 16KB 16.1KB/s 00:00 2.输入ctrl + z 暂停任务 输入ctrl + z 暂停 [1]+ Stopped scp -r /u01/media/Disk1/ 192.168.1.31:/u01/media/ [root@oradb30 ~]# 此时查看jobs: [root@oradb30 ~]# jobs [1]+ Stopped

让进程在后台可靠运行的几种方法

走远了吗. 提交于 2019-12-22 08:19:21
场景: 如果只是临时有一个命令需要长时间运行,什么方法能最简便的保证它在后台稳定运行呢? hangup 名称的来由 在 Unix 的早期版本中,每个终端都会通过 modem 和系统通讯。当用户 logout 时,modem 就会挂断(hang up)电话。 同理,当 modem 断开连接时,就会给终端发送 hangup 信号来通知其关闭所有子进程。 解决方法: 我们知道,当用户注销(logout)或者网络断开时,终端会收到 HUP(hangup)信号从而关闭其所有子进程。因此,我们的解决办法就有两种途径:要么让进程忽略 HUP 信号,要么让进程运行在新的会话里从而成为不属于此终端的子进程。 1. nohup nohup 无疑是我们首先想到的办法。顾名思义,nohup 的用途就是让提交的命令忽略 hangup 信号。让我们先来看一下 nohup 的帮助信息: NOHUP(1) User Commands NOHUP(1) NAME nohup - run a command immune to hangups, with output to a non-tty SYNOPSIS nohup COMMAND [ARG]... nohup OPTION DESCRIPTION Run COMMAND, ignoring hangup signals. --help display

nohup error no such file or directory

▼魔方 西西 提交于 2019-12-22 05:24:13
问题 I am trying to run a string of nohup commands to get server statistics. However I get an error of 'No such file or directory' . Note that the 3 nohup calls are embedded in a script which is executed through a cron job. And the first nohup works but the other 2 return an error. Ironically enough, when run on a different server, the script works fine. Commands nohup vmpstat -a -n 60 1000 > myvmstats (works) nohup mpstat -P ALL 1 1000 > mympstats (returns: nohup cannot run command mpstat : no

starting remote script via ssh containing nohup

爱⌒轻易说出口 提交于 2019-12-22 04:39:09
问题 I want to start a script remotely via ssh like this: ssh user@remote.org -t 'cd my/dir && ./myscript data my@email.com' The script does various things which work fine until it comes to a line with nohup: nohup time ./myprog $1 >my.log && mutt -a ${1%.*}/`basename $1` -a ${1%.*}/`basename ${1%.*}`.plt $2 < my.log 2>&1 & it is supposed to do start the program myprog, pipe its output to mylog and send an email with some datafiles created by myprog as attachment and the log as body. Though when

How do I run nohup as a different user without spawning two processes?

瘦欲@ 提交于 2019-12-21 10:16:13
问题 I'm trying to nohup a command and run it as a different user, but every time I do this two processes are spawned. For example: $ nohup su -s /bin/bash nobody -c "my_command" > outfile.txt & This definitely runs my_command as nobody, but there's an extra process that I don't want to shown up: $ ps -Af . . . root ... su -s /bin/bash nobody my_command nobody ... my_command And if I kill the root process, the nobody process still lives... but is there a way to not run the root process at all?

linux进程——后台运行的方法

狂风中的少年 提交于 2019-12-20 18:17:44
linux进程后台运行的几种方法: 我们经常会碰到这样的问题,用 telnet/ssh 登录了远程的 Linux 服务器,运行了一些耗时较长的任务, 结果却由于网络的不稳定导致任务中途失败。 如何让命令提交后不受本地关闭终端窗口/网络断开连接的干扰呢?下面举了一些例子, 您可以针对不同的场景选择不同的方式来处理这个问题。 如果只是临时有一个命令需要长时间运行,什么方法能最简便的保证它在后台稳定运行呢? 在 Unix 的早期版本中,每个终端都会通过 modem 和系统通讯。当用户 logout 时,modem 就会挂断(hang up)电话。 同理,当 modem 断开连接时,就会给终端发送 hangup 信号来通知其关闭所有子进程。 我们知道,当用户注销(logout)或者网络断开时,终端会收到 HUP(hangup)信号从而关闭其所有子进程。因此,我们的解决办法就有两种途径: 要么让进程忽略 HUP 信号,要么让进程运行在新的会话里从而成为不属于此终端的子进程。 1. nohup nohup 无疑是我们首先想到的办法。顾名思义,nohup 的用途就是让提交的命令忽略 hangup 信号。让我们先来看一下 nohup 的帮助信息: NOHUP(1) User Commands NOHUP(1) NAME nohup - run a command immune to hangups

Java程序以后台方式在Linux上运行(nohup命令)

馋奶兔 提交于 2019-12-20 13:38:33
一、预备 命令 :nohup java cn.aofeng.LoopApplication >Loop.log & 说明 : 1)将cn.aofeng.LoopApplication设置成后台运行,并且将标准输出的日志重定向至文件Loop.log。 2)nohup 表示不挂断运行,&表示以后台方式运行。 源代码: package cn.aofeng; import java.text.Format; import java.text.SimpleDateFormat; import java.util.Date; /** * * @author aofeng <a href="mailto:aofengblog@163.com"> aofengblog@163.com </a> * @version 1.0.0 * @since 1.0.0 */ public class LoopApplication { public static void main(String[] args) { Format format = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss" ); while ( true ) { String date = format.format( new Date()); System. out .println(

PYTHON的程序在LINUX后台运行

本小妞迷上赌 提交于 2019-12-20 13:35:22
1.nohup 命令 nohup   nohup 命令   用途:LINUX命令用法,不挂断地运行命令。   语法:nohup Command [ Arg ... ] [ & ]   描述:nohup 命令运行由 Command 参数和任何相关的 Arg 参数指定的命令,忽略所有挂断(SIGHUP)信号。在注销后使用 nohup 命令运行后台中的程序。要运行后台中的 nohup 命令,添加 & ( 表示“and”的符号)到命令的尾部。   如果不将 nohup 命令的输出重定向,输出将附加到当前目录的 nohup.out 文件中。如果当前目录的 nohup.out 文件不可写,输出重定向到 $HOME/nohup.out 文件中。如果没有文件能创建或打开以用于追加,那么 Command 参数指定的命令不可调用。如果标准错误是一个终端,那么把指定的命令写给标准错误的所有输出作为标准输出重定向到相同的文件描述符。   退出状态:该命令返回下列出口值:   126 可以查找但不能调用 Command 参数指定的命令。   127 nohup 命令发生错误或不能查找由 Command 参数指定的命令。   否则,nohup 命令的退出状态是 Command 参数指定命令的退出状态。   nohup命令及其输出文件   nohup命令:如果你正在运行一个进程