V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
cexia
V2EX  ›  Linux

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

  •  1
     
  •   cexia · 2016-06-13 11:26:37 +08:00 · 2692 次点击
    这是一个创建于 2873 天前的主题,其中的信息可能已经有所发展或是发生改变。

    遇到这么个问题:

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

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

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

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

    5 条回复    2016-06-13 13:32:42 +08:00
    knightdf
        1
    knightdf  
       2016-06-13 11:42:16 +08:00   ❤️ 1
    你需要一个日志模块, nohup.out 的 flush 根本不适合你做监控,你非要这么做的话就先自己 touch 一个 nohup.out 吧
    elgoog1970
        2
    elgoog1970  
       2016-06-13 11:51:52 +08:00   ❤️ 1
    touch nohup.out | chmod 755 nohup.out | ./runnable > nohup.out 2>&1 & 这样行么,其实也可以写个 shell 脚本,先 touch 在执行./runnable ...
    bearice
        3
    bearice  
       2016-06-13 11:53:22 +08:00   ❤️ 1
    man umask
    cexia
        4
    cexia  
    OP
       2016-06-13 13:17:48 +08:00
    @knightdf linux IO 重定向,认为不适合做监控,是因为写入延迟吗?
    elgoog1970
        5
    elgoog1970  
       2016-06-13 13:32:42 +08:00
    恩 设置 umask 值也可以。设置文件的默认权限
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5660 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 03:31 · PVG 11:31 · LAX 20:31 · JFK 23:31
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.