Topics: AIX, System Admin

How to run background jobs

There are a couple of options for running background jobs:

Option one:

Start the job as normal, then press CTRL-Z. It will say it is stopped, and then type "bg". It will continue in the background. Then type "fg", if you want it to run in the foreground again. You can repeat typing CTRL-Z, bg, fg as much as you like. The process will be killed once you log out. You can avoid this by running: nohup command.

Option two:

Use the at command: run the command as follows:

# echo "command" | at now
This will start it in the background and it will keep on running even if you log out.

Option three:

Run it with an ampersand: command &

This will run it in the background. But the process will be killed if you log out. You can avoid the process being killed by running: nohup command &.

Option four:

Schedule it one time in the crontab.

With all options, make sure you redirect any output and errors to a file, like:
# command > command.out 2>&1

If you found this useful, here's more on the same topic(s) in our blog:

UNIX Health Check delivers software to scan Linux and AIX systems for potential issues. Run our software on your system, and receive a report in just a few minutes. UNIX Health Check is an automated check list. It will report on perfomance, capacity, stability and security issues. It will alert on configurations that can be improved per best practices, or items that should be improved per audit guidelines. A report will be generated in the format you wish, and the report includes the issues discovered and information on how to solve the issues as well.

Interested in learning more?