Running scripts or processes even if the user logs out

May 4, 2021

Comments

Adsense

Adsense

Adsense

Adsense

Sometimes, we may need our script to run even after we log out, such as when making a backup and similar activities. In this case, even if we log out, the system is powered on and running. In such situations, we can use the nohup command. The nohup command prevents the process from terminating by using the SIGHUP signal.

The nohup command makes our script run without attaching it to a Terminal. Therefore, if we use the echo command to print text on the Terminal it will not be printed in a Terminal, since the script is not attached to a Terminal. In such cases, we need to redirect the output to the file, or nohup will automatically redirect the output to a nohup.out file.

Therefore, if we need to run a process, even if we log out, we need to use the nohup command as follows:

$ nohup command &

The example is as follows:

$ nohup sort emp.lst &

This will run a program to sort the emp.lst file in the background.

$ nohup date &
Satish Kumar

Satish Kumar

I am Satish Kumar, Founder of LinuxConcept. Linux and F.O.S.S enthusiast, love to work on open source platform and technologies.

Adsense

Adsense

Adsense

Adsense

Adsense

Adsense

Adsense

Adsense

Adsense

Related Posts

Backup of files in Linux using command line

In IT or our day-to-day computer industry activities, taking backup is one of the most important activities. Previously, offices were required to keep important paper in a safe place; but if a fire breaks out, then everything is finished. In the digital world, taking...

Using awk in Linux

awk is a program that has its own programming language for performing data-processing and generating reports. The GNU version of awk is gawk. awk processes data, which can be received from a standard input, input file, or as the output of any other command or process....

0 Comments

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

1 × 3 =

News & Updates

Join Our Newsletter

Adsense

Adsense

Adsense

Adsense