When working within any UNIX-like terminal, being able to save time is on every system administrators mind. With that come tips and tricks for smoothly navigating your way through the terminal. In this Monthly Linux Tip, we will look at one of those tips and tricks; nohup.
nohup (short for no hangups) is to be used in tandem with a subsequent command, that it executes in the background. This is particularly helpful when you are performing ArcGIS Enterprise workflows. To better guide us in this blog, we will break down the examples into different sections, outlined in our table of contents.
- Introducing nohup
- Using nohup in the background
- Conclusion
1. Introducing nohup
Let’s see an example of nohup’s usage below with publishing services in batch to our Enterprise Portal:
So what’s going on here? By running the nohup command ahead of our batch-publishing.sh Bash script, I am outsourcing the output. By default, that goes into a generated file called nohup.out, but that can be redirected to a filename of your choosing.
Once the script finishes, we are back at our shell prompt as seen below:
Using an editor or simply running the cat command, we can investigate the results of the command.
2. Using nohup in the background
The above example is great, but we desire more. We need to be able to place this in the background while we work on other important tasks. Luckily, nohup offers that flexibility as well. We can simply modify the above example to show the following:
Simply adding the & sign at the end places our task in the background! Notice that immediately following is the PID associated with this command. As this command is in the background, you can press ‘Enter’ on your keyboard and let the command play out.
As with before, you can track the progress inside the nohup.out file. Additionally, as this is in the background, using the fg command, you can bring the nohup back into the foreground.
3. Conclusion
The nohup command can be a powerful command to help further streamline your ArcGIS Enterprise workflows. It is simple to use and is a great tool to add to your Linux toolbox. That is all for this month’s blog, thank you for reading this Monthly Linux Tip.
Article Discussion: