2.6 Given a scenario, automate and schedule jobs Flashcards
Chron
The cron service allows you to schedule processes to run at specific times. The service makes use of the crond daemon, which checks every minute to see what processes should be executed. This section describes how to use this service and how to use the at command
AT
The at command is used to schedule one or more commands to be executed at one specific time in the future. The syntax for the command is at time, where time indicates when you want to execute a command. For example, the following command will allow you to schedule a command to run at 5 p.m. tomorrow:
at 5pm tomorrow
at>
chrontab
The crontab command allows a user to view or modify her crontab file. The crontab file allows a user to schedule a command to be executed on a regular basis, such as once an hour or twice a month.
FG
A paused process can be restarted in the foreground by using the fg command:
[student@OCS ~]$ jobs
[1]+ Stopped sleep 999
[student@OCS ~]$ fg %1
sleep 999
BG
A paused process can be restarted in the background by using the bg command:
[student@OCS ~]$ jobs
[1]+ Stopped sleep 999
[student@OCS ~]$ bg %1
[1]+ sleep 999 &
[student@OCS ~]$ jobs
[1]+ Running sleep 999 &
&
By default, processes started on the command line are run in the foreground. This means that the BASH shell is not accessible until the process that is running in the foreground is terminated.
Running a process in the background allows you to continue to work in the BASH shell and execute additional commands. To execute a process in the background, add an & character to the end of the command, like so:
[student@OCS ~]$ xeyes &
KILL
The kill command can be used to change the state of a process, including stopping (killing) it.
kill PID|jobnumber
CTRL-C
When a process is running in the foreground, a SIGINT signal can be sent to a process by holding down the Ctrl key and pressing the letter c. A SIGINT signal is designed to stop a program prematurely
CTRL-Z
When a process is running in the foreground, a SIGTSTP signal can be sent to a process by holding down the Ctrl and pressing the letter z. A SIGTSTP signal is designed to pause a program. The program can then be restarted by either the bg or the fg command
NOHUP
Each process has a parent process that started it. For example, if you execute a command in a BASH shell, that command’s parent process is the BASH shell process.
When a parent process is stopped, a hang-up (HUP) signal is sent to all the child processes. This HUP signal is designed to stop the child processes. By default, a child process will stop when sent an HUP signal.