Skip to content

Commit

Permalink
nohup trick
Browse files Browse the repository at this point in the history
  • Loading branch information
sosiristseng committed Jan 4, 2025
1 parent a0a1eed commit deda53f
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions docs/software/nohup.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,38 @@ 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
```

## 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
}
```

0 comments on commit deda53f

Please sign in to comment.