diff --git a/docs/software/nohup.md b/docs/software/nohup.md index d3af9d4..384d4bc 100644 --- a/docs/software/nohup.md +++ b/docs/software/nohup.md @@ -25,7 +25,7 @@ The output will be in `nohup.out` by default. If you want to customize the outpu nohup mycmd &> log.txt & ``` -To monitor what is inside `nohup.out` +To monitor what is going on in `nohup.out` ```sh tail -f nohup.out @@ -33,9 +33,30 @@ tail -f nohup.out ## End the running process -When you're done, you can kill the process by the process ID (PID). +You can kill the ongoing process by the process ID (PID). ```sh ps -aux | grep mycmd kill PID ``` + +## Run a background process with sudo and nohup + +Use `sudo -b CMD` + +```sh +nohup sudo -b CMD +``` + +## Limit the size of nohup.out + +Use [logrotate](https://linux.die.net/man/8/logrotate). Configure something like this in `/etc/logrotate.conf` + +```txt title="/etc/logrotate.conf" +/path/to/nohup.out { + size 1024k + copytruncate + rotate 100 + maxage 100 +} +```