Pushing an cli app to the background


Recommended Posts

I am new to unraid and evaluating it.  I am transferring data from my old NAS to my new unraid box using rsync on the cli.  When I attempt to push the command to the background with "nohup &" but when I log off and back on my rsync job has been terminated.  Help me understand why this is.

 

Last login: Tue Aug 13 21:09:52 2019 from 192.168.1.187
Linux 4.19.56-Unraid.
root@nas01:~# jobs
root@nas01:~# nohup rsync -avhP --compress --append-verify /tmp/multimedia/ /mnt/user/multimedia/&
[1] 20461
root@nas01:~# nohup: ignoring input and appending output to 'nohup.out'

root@nas01:~# jobs
[1]+  Running                 nohup rsync -avhP --compress --append-verify /tmp/multimedia/ /mnt/user/multimedia/ &
root@nas01:~# df -h
Filesystem               Size  Used Avail Use% Mounted on
rootfs                    16G  865M   15G   6% /
tmpfs                     32M  288K   32M   1% /run
devtmpfs                  16G     0   16G   0% /dev
tmpfs                     16G   41M   16G   1% /dev/shm
cgroup_root              8.0M     0  8.0M   0% /sys/fs/cgroup
tmpfs                    128M  2.0M  127M   2% /var/log
/dev/sda1                956M  180M  776M  19% /boot
/dev/loop0               8.7M  8.7M     0 100% /lib/modules
/dev/loop1               5.9M  5.9M     0 100% /lib/firmware
192.168.1.3:/Software     22T   22T  433G  99% /tmp/software
192.168.1.3:/Backup       22T   22T  433G  99% /tmp/backup
192.168.1.3:/Download     22T   22T  433G  99% /tmp/download
/dev/md1                 3.7T  597G  3.1T  17% /mnt/disk1
/dev/md2                 3.7T  3.8G  3.7T   1% /mnt/disk2
/dev/md3                 3.7T  3.8G  3.7T   1% /mnt/disk3
/dev/md4                 3.7T  3.8G  3.7T   1% /mnt/disk4
/dev/md5                 3.7T  3.8G  3.7T   1% /mnt/disk5
shfs                      19T  612G   18T   4% /mnt/user
/dev/loop2                20G  403M   20G   3% /var/lib/docker
/dev/loop3               1.0G   17M  905M   2% /etc/libvirt
shm                       64M     0   64M   0% /var/lib/docker/containers/479d680b0aa8101af5fb92fd4540e80ec7db67134eb81fd61471f7c97f259249/mounts/shm
192.168.1.3:/Multimedia   22T   22T  433G  99% /tmp/multimedia
root@nas01:~# 

 

Link to comment

The reason nohup doesn't work for this is because when you disconnect, or log out of that terminal, that terminal, and any child processes of the terminal are killed. This is just Linux kernel process management doing it's job. To prevent this you can just disown the process, no need to nohup it.

For example you can:


$ processname &

$ disown

and "processname" will continue running after the terminal is killed. This is good because it means that "processname" will still respond to hangup, which may be needed.

 

Of course, you could also call disown with nohup:


$ nohup processname

$ disown

 

You can also disown processes by using their PID, but calling it immediately following the spawn of a process will automatically disown the last created child.

  • Thanks 1
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.