echo 123 > `date +%Y-%m-%d-%H.tmp`

echo 123 > /home/`date +%Y-%m-%d-%H.tmp`

nohup --help

[root@Today data]# nohup --help
Usage: nohup COMMAND [ARG]...
or: nohup OPTION
Run COMMAND, ignoring hangup signals.

--help display this help and exit
--version output version information and exit

If standard input is a terminal, redirect it from /dev/null.
If standard output is a terminal, append output to 'nohup.out' if possible,
'$HOME/nohup.out' otherwise.
If standard error is a terminal, redirect it to standard output.
To save output to FILE, use 'nohup COMMAND > FILE'.

NOTE: your shell may have its own version of nohup, which usually supersedes
the version described here. Please refer to your shell's documentation
for details about the options it supports.

GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
For complete documentation, run: info coreutils 'nohup invocation'
[root@Today data]# nohup --help

nohup python /root/path/Biz.py start >> /data/log/Biz/`date +%Y-%m-%d-%H.nohup.out`

nohup: ignoring input and redirecting stderr to stdout

始终在内存?

批量写入?

nohup python /home/ctGO/goEchopublic/t.py  > /var/`date +%Y-%m-%d-%H.nohup.out`

Unix Nohup: Run a Command or Shell-Script Even after You Logout https://linux.101hacks.com/unix/nohup-command/

Unix Nohup: Run a Command or Shell-Script Even after You Logout

by SATHIYAMOORTHY

When you execute a Unix job in the background ( using &, bg command), and logout from the session, your process will get killed. You can avoid this using several methods — executing the job with nohup, or making it as batch job using at, batch or cron command.

This quick tip is for beginners. If you’ve been using nohup for a while, leave us a comment and tell us under what situations you use nohup.

In this quick tip, let us review how to make your process running even after you logout, using nohup.

Nohup stands for no hang up, which can be executed as shown below.

nohup syntax:

# nohup command-with-options &

Nohup is very helpful when you have to execute a shell-script or command that take a long time to finish. In that case, you don’t want to be connected to the shell and waiting for the command to complete. Instead, execute it with nohup, exit the shell and continue with your other work.

Explanation about nohup.out file

By default, the standard output will be redirected to nohup.out file in the current directory. And the standard error will be redirected to stdout, thus it will also go to nohup.out. So, your nohup.out will contain both standard output and error messages from the script that you’ve executed using nohup command.

Instead of using nohup.out, you can also redirect the output to a file using the normal shell redirections.

Example: Printing lines to both standard output & standard error

while(true)
do
echo "standard output"
echo "standard error" 1>&2
sleep 1;
done

Execute the script without redirection

$ nohup sh custom-script.sh &
[1] 12034
$ nohup: ignoring input and appending output to `nohup.out' $ tail -f nohup.out
standard output
standard error
standard output
standard error
..

Execute the script with redirection

$ nohup sh custom-script.sh > custom-out.log &
[1] 11069
$ nohup: ignoring input and redirecting stderr to stdout $ tail -f custom-out.log
standard output
standard error
standard output
standard error
..

If you log-out of the shell and login again, you’ll still see the custom-script.sh running in the background.

$ ps aux | grep sathiya
sathiya 12034 0.0 0.1 4912 1080 pts/2 S 14:10 0:00 sh custom-script.sh Linux: Start Command In Background - nixCraft https://www.cyberciti.biz/faq/linux-command-line-run-in-background/

Linux: Start Command In Background

last updated February 13, 2014 in CategoriesBASH ShellKSH ShellLinuxUNIX

Iam a new Linux command line user. How do I start or run command in the background so that I can access command prompt immediately?

A command that has been scheduled nonsequentially is called background process. You can not see the background processes on screen. For example, Apache httpd server runs in background to serve web pages. You can put your shell script or any command in background.

Syntax

You can put a task (such as command or script) in a background by appending a & at the end of the command line. The & operator puts command in the background and free up your terminal. The command which runs in background is called a job. You can type other command while background command is running. The syntax is:

command &
script-name &
/path/to/command arg1 arg2 &
command-1 | command-2 arg1 &
command-1 | command-2 -arg1 -arg2 >/path/to/output &

Examples

Put the ls command in the background, enter:
$ ls *.py > output.txt &
Put the following find command in a background by putting a ‘&’ at the end of the command line:

find . -iname "*.mp3" > myplaylist.txt &

Sample outputs:

Fig.01: Linux background job in action (click to enlarge)

How do I see jobs running in the background?

Type the following command:
jobs
Sample outputs:

[1]-  Running                 find / -iname "*.c" 2> /dev/null > /tmp/output.txt &
[2]+ Running grep -R "hostNamed" / 2> /dev/null > /tmp/grep.txt &

Where,

  • [1] and [2] are job IDS.

To see process IDs for JOB IDs in addition to the normal information pass the -loption:
jobs -l
Sample outputs:

[1]-  7307 Running                 find / -iname "*.c" 2> /dev/null > /tmp/output.txt &
[2]+ 7324 Running grep -R "hostNamed" / 2> /dev/null > /tmp/grep.txt &

To see process IDs only, enter:
jobs -p
Sample outputs:

7307
7324

How do I kill the jobs running in the background?

Use the kill command to kill process either gracefully or forcefully. The syntax is:

kill PID
kill -15 PID
kill -9 PID
killall process-Name-Here
killall -15 process-Name-Here
killall -9 process-Name-Here

See how to use killall command under Linux operating system for more information.

How do I bring process running in the background to the foreground?

The syntax is:
%JOB-ID
OR
fg JOB-ID
First, list the current jobs with jobs command, enter:
jobs -l
Sample outputs:

[1]-  7307 Running                 find / -iname "*.c" 2> /dev/null > /tmp/output.txt &
[2]+ 7324 Running grep -R "hostNamed" / 2> /dev/null > /tmp/grep.txt &

To bring the job id #2 to the foreground, enter:
%2
OR use fg command:
fg 2
Sample outputs:

grep -R "hostNamed" / 2> /dev/null > /tmp/grep.txt

To send back this job in the background hit CTRL-Z i.e. while holding the CTRL key, press z key. This will suspend the current foreground job. Type the following command to send back the job in the background:
%2 &
OR use bg command:
bg
The grep command job is now running in the background.

Summary of all useful commands

Description Command
To see which jobs are still running jobs jobs
jobs -l
ps aux
To put a command / script to the background command &
/path/to/command &
/path/to/script arg1 &
To bring a background job to the foreground fg n
%n
To send a job to the background without canceling it bg n
%n &

Note: n == Job id (use jobs command to see job id)..

See also:
nohup(1) - Linux man page https://linux.die.net/man/1/nohup

输出哪种信息:py-print、ctrl终止  :需要实际测试 环境  

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 this help and exit
--version
output version information and exit

If standard input is a terminal, redirect it from /dev/null. If standard output is a terminal, append output to 'nohup.out' if possible, '$HOME/nohup.out' otherwise. If standard error is a terminal, redirect it to standard output. To save output to FILE, use 'nohup COMMAND > FILE'.

NOTE: your shell may have its own version of nohup, which usually supersedes the version described here. Please refer to your shell's documentation for details about the options it supports.

cat t.py
while 2>1:
print(2)

out中写入了print信息
nohup python /data/log/directAd/t.py >> /data/log/directAd/`date +%Y-%m-%d-%H.nohupT.out
传入参数,虽然脚本正常执行,但是out中没有写入print信息
nohup python /root/tools/trunk/bin/DirectServer.py start >> /data/log/directAd/`date +%Y-%m-%d-%H.nohup.out`


时间写入文件名 nohup 原理 Command In Background your shell may have its own version of nohup的更多相关文章

  1. linux的fwrite()使用方法,当前时间写入文本的程序

    fwrite函数 1.函数功能 用来读写一个数据块. 2.一般调用形式 fwrite(buffer,size,count,fp); 3.说明 (1)buffer:是一个指针,对fread来说,它是读入 ...

  2. 浅析 Linux 中的时间编程和实现原理一—— Linux 应用层的时间编程【转】

    本文转载自:http://www.cnblogs.com/qingchen1984/p/7007631.html 本篇文章主要介绍了"浅析 Linux 中的时间编程和实现原理一—— Linu ...

  3. 迄今为止最硬核的「Java8时间系统」设计原理与使用方法

    为了使本篇文章更容易让读者读懂,我特意写了上一篇<任何人都需要知道的「世界时间系统」构成原理,尤其开发人员>的科普文章.本文才是重点,绝对要读,走起! Java平台时间系统的设计方案 几乎 ...

  4. IIS短文件名漏洞原理与挖掘思路

    首先来几个网址先了解一下 https://www.jb51.net/article/166405.htm https://www.freebuf.com/articles/web/172561.htm ...

  5. /usr/local/lib/ruby/gems/2.4.0/gems/cocoapods-1.5.3/lib/cocoapods/command.rb:118:in `git_version': Failed to extract git version from `git --version`

    问题及分析 今天做项目的时候,执行pod update报了如下错误信息: /usr/local/lib/ruby/gems/2.4.0/gems/cocoapods-1.5.3/lib/cocoapo ...

  6. Ubuntu 16.04将系统时间写入到硬件时间BIOS

    说明:在Ubuntu中为了和Windows保持一致,会将系统时间设置成CST的,所以下面的说法是设置成UTC的问题是由于所在的环境不一致导致的,本章只讨论如何设置时间到BIOS,不做时区分析,下面忽略 ...

  7. postgresql获取表最后更新时间(通过触发器将时间写入另外一张表)

    通过触发器方式获取表最后更新时间,并将时间信息写入到另外一张表 一.创建测试表和表记录更新时间表 CREATE TABLE weather( city varchar(80), temp_lo int ...

  8. hystrix ,feign,ribbon的超时时间配置,以及原理分析

    背景,网上看到很多关于hystrix的配置都是没生效的,如: 一.先看测试环境搭建: order 服务通过feign 的方式调用了product 服务的getProductInfo 接口 //---- ...

  9. Django把现在时间写入数据库,模板渲染在页面中

    1. 导入time模块 import time 2. 获取现在时间,使用"年-月-日 时:分:秒"这样的模板,赋值给变量 在views.py中: pt = time.strftim ...

随机推荐

  1. Codeforces 631B Print Check (思维)

    题目链接 Print Check 注意到行数加列数最大值只有几千,那么有效的操作数只有几千,那么把这些有效的操作求出来依次模拟就可以了. #include <bits/stdc++.h> ...

  2. scanf格式控制符之%[]的应用

    考虑只读入小写字母的字符串,这个问题要如何用scanf解决呢? 这就用到了%[] 这个格式控制符,它支持a-z这样的格式控制 char s[111]; scanf("%[a-z]" ...

  3. HNOI 2006 BZOJ 1195 最短母串

    题面 问题描述 给定n个字符串(S1,S2,„,Sn),要求找到一个最短的字符串T,使得这n个字符串(S1,S2,„,Sn)都是T的子串. 输入 第一行是一个正整数n(n<=12),表示给定的字 ...

  4. 转:如何将 Java 项目转换成 Maven 项目

    如何将 Java 项目转换成 Maven 项目 本文内容 Java 项目 Maven 项目 Java 项目转换成 Maven 项目 本文主要介绍如何将 Java 项目转换成 Maven 项目.首先要明 ...

  5. 使用nginx实现的灰度发布思路研究(待实践)

    灰度发布也叫 A/B 测试,原理是一套系统在实现了负载均衡,全国节点都部署了系统之后,可以在新功能上线后,让一小部分用户先使用,从中收集使用信息来做对比和发现bug,及时调整,最终分发到全国的节点. ...

  6. 快速建立ssh互信(转)

    转自:魏巍的Linux酒吧 - 51CTO技术博客(http://weiweilinux.blog.51cto.com/3349074/1048212) 快速建立ssh互信 因为工作中经常需要配置服务 ...

  7. IIC设备驱动程序

    IIC设备是一种通过IIC总线连接的设备,由于其简单性,被广泛引用于电子系统中.在现代电子系统中,有很多的IIC设备需要进行相互之间通信 IIC总线是由PHILIPS公司开发的两线式串行总线,用于连接 ...

  8. Linux执行命令unable to create new native thread问题

    对于系统的Linux的问题 主要是线程数有限制max user processes 参数限制 修改这个参数涉及到修改两个文件 vi /etc/security/limits.conf 增加如下内容: ...

  9. 【Python】从文件中读取数据

    从文件中读取数据 1.1 读取整个文件 要读取文件,需要一个包含几行文本的文件(文件PI_DESC.txt与file_reader.py在同一目录下) PI_DESC.txt 3.1415926535 ...

  10. mysql启动參数(/etc/my.cnf)具体解释汇总

    在linux以下的/etc/my.cnf的參数具体解释汇总 MYSQL–my.cnf配置中文具体解释 basedir = path   使用给定文件夹作为根文件夹(安装文件夹). character- ...