Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
cexia
V2EX  ›  Linux

linux I/O 重定向文件权限设置

  •  1
     
  •   cexia · Jun 13, 2016 · 3610 views
    This topic created in 3620 days ago, the information mentioned may be changed or developed.

    遇到这么个问题:

    在 centos 上运行 shell 命令 “./runnable > nohup.out 2>&1 &”

    运行 runnable 程序,并把 stdout 和 stderr 重定向到 nohup.out 。

    有一个外部程序会监控这个 nohup.out 文件,需要一定的权限才能访问。

    想请问各位是否有办法在运行上述这行命令时,可以指定 nohup.out 的文件权限(比如设置为 0755 )?

    5 replies    2016-06-13 13:32:42 +08:00
    knightdf
        1
    knightdf  
       Jun 13, 2016   ❤️ 1
    你需要一个日志模块, nohup.out 的 flush 根本不适合你做监控,你非要这么做的话就先自己 touch 一个 nohup.out 吧
    elgoog1970
        2
    elgoog1970  
       Jun 13, 2016   ❤️ 1
    touch nohup.out | chmod 755 nohup.out | ./runnable > nohup.out 2>&1 & 这样行么,其实也可以写个 shell 脚本,先 touch 在执行./runnable ...
    bearice
        3
    bearice  
       Jun 13, 2016   ❤️ 1
    man umask
    cexia
        4
    cexia  
    OP
       Jun 13, 2016
    @knightdf linux IO 重定向,认为不适合做监控,是因为写入延迟吗?
    elgoog1970
        5
    elgoog1970  
       Jun 13, 2016
    恩 设置 umask 值也可以。设置文件的默认权限
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5734 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 36ms · UTC 01:44 · PVG 09:44 · LAX 18:44 · JFK 21:44
    ♥ Do have faith in what you're doing.