在 Debian 里用 nohup 跑程序,日志一般是通过 shell 重定向生成的,比如:
nohup your_command > app.log 2>&1 &
日志文件的权限由谁决定?
022644(rw-r--r--)umask 027
nohup your_command > app.log 2>&1 &
结果:640(rw-r-----)
chmod 640 app.log
chown appuser:appgroup app.log
touch app.log
chmod 640 app.log
chown appuser:appgroup app.log
nohup your_command >> app.log 2>&1 &
如果你在 Debian 上长期跑服务,建议用 systemd:
[Service]
User=appuser
StandardOutput=append:/var/log/app/app.log
StandardError=append:/var/log/app/app.log
然后:
chown -R appuser:appgroup /var/log/app
chmod 750 /var/log/app
/var/log/yourapp/640 或 750777如果你能说下:
我可以给你一个更合适的权限方案。