User Tools

Site Tools


processes-and-jobs

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
processes-and-jobs [2019/10/08 16:27]
Miroslav Bernát
processes-and-jobs [2020/02/29 01:47] (current)
Miroslav Bernát
Line 7: Line 7:
 | **systemctl** <​command>​ <​service>​\\ (implemented from RHEL 7) | depending on the specified command (**start**, **stop**, **restart**,​ **reload**, **status**) starts / stops / restarts / reloads configuration file / shows status of a service („service unit“)\\ ''#​ systemctl restart crond(.service)''​\\ ''#​ systemctl list-units -t service''​\\ (shows the status of installed services)\\ ''#​ systemctl list-units -t service --state=running''​\\ (shows running services)\\ ''#​ systemctl list-units -t service --all''​\\ (shows the status of all services) | | **systemctl** <​command>​ <​service>​\\ (implemented from RHEL 7) | depending on the specified command (**start**, **stop**, **restart**,​ **reload**, **status**) starts / stops / restarts / reloads configuration file / shows status of a service („service unit“)\\ ''#​ systemctl restart crond(.service)''​\\ ''#​ systemctl list-units -t service''​\\ (shows the status of installed services)\\ ''#​ systemctl list-units -t service --state=running''​\\ (shows running services)\\ ''#​ systemctl list-units -t service --all''​\\ (shows the status of all services) |
 | **systemctl daemon-reload**\\ (implemented from RHEL 7) | reloads the systemd process configuration | | **systemctl daemon-reload**\\ (implemented from RHEL 7) | reloads the systemd process configuration |
-| **bash** / **sh** <​file>​ | executes a (read-only) file in a subshell; the file is being searched for in the current directory and in $PATH, **-x** runs the script in a debug mode, **-c** <commandexecutes a command in a subshell\\ ''​$ sudo bash -c "echo '​Welcome to my website'​ > /​var/​www/​html/​index.html"''​ |+| **bash** / **sh** <​file>​ | executes a (read-only) file in a subshell; the file is being searched for in the current directory and in $PATH, **-x** runs the script in a debug mode, **-c** <stringcommands are read from the string, **-s** commands are read from STDIN\\ ''​$ sudo bash -c "echo '​Welcome to my website'​ > /​var/​www/​html/​index.html"''​ |
 | **source** / **.** <​file>​ | executes a (read-only) file in the current shell; the file is being searched for in the current directory and in $PATH\\ ''​$ . ~/​.bash_profile''​\\ (refreshes a user profile without the necessity to log off and log on) | | **source** / **.** <​file>​ | executes a (read-only) file in the current shell; the file is being searched for in the current directory and in $PATH\\ ''​$ . ~/​.bash_profile''​\\ (refreshes a user profile without the necessity to log off and log on) |
 | <​file_name>​ / <​path_to_the_file>​ | executes an executable file in a subshell; the file is being searched for in $PATH or in the specified path\\ ''​$ ./​script''​ | | <​file_name>​ / <​path_to_the_file>​ | executes an executable file in a subshell; the file is being searched for in $PATH or in the specified path\\ ''​$ ./​script''​ |
Line 16: Line 16:
 | **nice**\\ **nice** (**-n** <​priority>​) <​command>​ | prints the current process scheduling priority (standard is 0)\\ runs a program with a modified scheduling priority (parameter „priority“ specifies a value that is going to be removed or added to the standard value, if it is omitted, the value is automaticaly decreased by 10; the priority is specified in the range between -20 and 19, the lower number – the higher priority, the minus values can be set by root only)\\ ''​$ nice -n 15 rm -rf ~/​tmp/​*''​\\ (decreases the process priority by 15)\\ ''#​ nice -n -15 ls /etc | cpio -ov > /​dev/​rmt0''​\\ (increases the process priority by 15) | | **nice**\\ **nice** (**-n** <​priority>​) <​command>​ | prints the current process scheduling priority (standard is 0)\\ runs a program with a modified scheduling priority (parameter „priority“ specifies a value that is going to be removed or added to the standard value, if it is omitted, the value is automaticaly decreased by 10; the priority is specified in the range between -20 and 19, the lower number – the higher priority, the minus values can be set by root only)\\ ''​$ nice -n 15 rm -rf ~/​tmp/​*''​\\ (decreases the process priority by 15)\\ ''#​ nice -n -15 ls /etc | cpio -ov > /​dev/​rmt0''​\\ (increases the process priority by 15) |
 | **renice** **-n** <​priority>​ <​identifier>​ | alters the priority of a running process (the value of the priority is specified in the absolute form), (**-p**) <PID> applies to a specified process, **-u** <​user>​ applies to all processes of a specified user, **-g** <​group>​ applies to all processes of a specified group\\ ''#​ renice -n 5 987''​\\ ''#​ renice -n -20 -u root''​\\ (increases the priority of all processes belonging to root to the maximum)\\ ''#​ renice -n 19 -g users''​\\ (decreases the priority of all processes belonging to group users to the minimum) | | **renice** **-n** <​priority>​ <​identifier>​ | alters the priority of a running process (the value of the priority is specified in the absolute form), (**-p**) <PID> applies to a specified process, **-u** <​user>​ applies to all processes of a specified user, **-g** <​group>​ applies to all processes of a specified group\\ ''#​ renice -n 5 987''​\\ ''#​ renice -n -20 -u root''​\\ (increases the priority of all processes belonging to root to the maximum)\\ ''#​ renice -n 19 -g users''​\\ (decreases the priority of all processes belonging to group users to the minimum) |
-| **ctrl**+**c** | terminates a running ​command ​in the foreground | +| **Ctrl**+**c** | terminates a running ​process ​in the foreground | 
-| **ctrl**+**d** | terminates a running ​program ​that reads data from STDIN |+| **Ctrl**+**d** | terminates a running ​process ​that reads data from STDIN / exits the current shell |
 | **kill** (<​signal>​) <PID> / **%**<​job_number>​ | terminates a specified process in a standard way (sends signal 15 – SIGTERM), **-9** terminates a process immediately (signal SIGKILL), **-1** terminates a process, if the signal is sent to a daemon, it reloads its configuration file (signal SIGHUP), **-19** suspends a process (signal SIGSTOP), **-18** starts a suspended process (signal SIGCONT), **-l** prints a list of all signal names\\ ''​$ kill -9 2051''​ / ''​kill -SIGKILL 2051''​ / ''​kill -KILL 2051''​ / ''​kill -sigkill 2051''​ / ''​kill -kill 2051''​\\ ''​$ kill %3''​ | | **kill** (<​signal>​) <PID> / **%**<​job_number>​ | terminates a specified process in a standard way (sends signal 15 – SIGTERM), **-9** terminates a process immediately (signal SIGKILL), **-1** terminates a process, if the signal is sent to a daemon, it reloads its configuration file (signal SIGHUP), **-19** suspends a process (signal SIGSTOP), **-18** starts a suspended process (signal SIGCONT), **-l** prints a list of all signal names\\ ''​$ kill -9 2051''​ / ''​kill -SIGKILL 2051''​ / ''​kill -KILL 2051''​ / ''​kill -sigkill 2051''​ / ''​kill -kill 2051''​\\ ''​$ kill %3''​ |
 | **killall** (<​signal>​) <​process_name>​ | terminates a specified process by its name (useful especially when more running processes are associated with one program); the process is terminated in a standard way (sends signal 15 – SIGTERM), **-9** terminates a process immediately (signal SIGKILL), **-19** suspends a process (signal SIGSTOP), **-18** starts a suspended process (signal SIGCONT), **-l** prints a list of all signal names, **-u** <​user>​ terminates all processes of a specified user\\ ''#​ killall -9 sshd''​ | | **killall** (<​signal>​) <​process_name>​ | terminates a specified process by its name (useful especially when more running processes are associated with one program); the process is terminated in a standard way (sends signal 15 – SIGTERM), **-9** terminates a process immediately (signal SIGKILL), **-19** suspends a process (signal SIGSTOP), **-18** starts a suspended process (signal SIGCONT), **-l** prints a list of all signal names, **-u** <​user>​ terminates all processes of a specified user\\ ''#​ killall -9 sshd''​ |
Line 28: Line 28:
 | **jobs** | prints suspended jobs and jobs running in the background, **-l** including PID, **-n** prints the changes from the previous execution only | | **jobs** | prints suspended jobs and jobs running in the background, **-l** including PID, **-n** prints the changes from the previous execution only |
 | <​command>​ **&** | executes a job in the background | | <​command>​ **&** | executes a job in the background |
-| **ctrl**+**z** | suspends a running job in the foreground |+| **Ctrl**+**z** | suspends a running job in the foreground |
 | **bg** (**%**<​job_number>​) | moves a suspended job to the background; without an argument the last suspended job is moved | | **bg** (**%**<​job_number>​) | moves a suspended job to the background; without an argument the last suspended job is moved |
 | **fg** (**%**<​job_number>​) | moves a suspended or background job to the foreground; without an argument the last suspended job or the last running background job is moved | | **fg** (**%**<​job_number>​) | moves a suspended or background job to the foreground; without an argument the last suspended job or the last running background job is moved |
 | **nohup** <​command>​ | executes a command ignoring SIGHUP signals (it runs even if the user has logged out); the output of the command is saved in „nohup.out“ file in the current directory\\ ''#​ nohup find /tmp -name core -print > core.txt &''​ | | **nohup** <​command>​ | executes a command ignoring SIGHUP signals (it runs even if the user has logged out); the output of the command is saved in „nohup.out“ file in the current directory\\ ''#​ nohup find /tmp -name core -print > core.txt &''​ |
-| **watch** <​command>​ | executes a command repeatedly in regular intervals of 2 seconds, **-n** <n> every //n// seconds, **-d** highlights the changes in the output, **ctrl**+**c** terminates the program\\ ''​$ watch -n 1 date''​\\ ''​$ watch -d iostat''​\\ ''​$ watch "ps -eo pcpu,​pid,​user,​args --sort=-pcpu | head -10"''​ |+| **watch** <​command>​ | executes a command repeatedly in regular intervals of 2 seconds, **-n** <n> every //n// seconds, **-d** highlights the changes in the output, **Ctrl**+**c** terminates the program\\ ''​$ watch -n 1 date''​\\ ''​$ watch -d iostat''​\\ ''​$ watch "ps -eo pcpu,​pid,​user,​args --sort=-pcpu | head -10"''​ |
 | **wait** (<​PID>​ / **%**<​job_number>​) | waits for a specified process or job running in the background of the current shell to finish, then terminates; it returns the last process termination status, if the process doesn'​t exist, the return code is „127“; without an argument waits for all the current shell background processes to terminate and the return code is „0“\\ ''​$ wait $! && echo „OK“ || echo „KO“''​ | | **wait** (<​PID>​ / **%**<​job_number>​) | waits for a specified process or job running in the background of the current shell to finish, then terminates; it returns the last process termination status, if the process doesn'​t exist, the return code is „127“; without an argument waits for all the current shell background processes to terminate and the return code is „0“\\ ''​$ wait $! && echo „OK“ || echo „KO“''​ |
 | **sleep** <​number>​(<​unit_of_time>​) | sets a time interval in seconds during which no activity is performed (useful especially when a certain delay is needed before executing the following command), **m** in minutes, **h** in hours, **d** in days\\ ''​$ sleep 10 && echo "10 seconds have passed."''​ | | **sleep** <​number>​(<​unit_of_time>​) | sets a time interval in seconds during which no activity is performed (useful especially when a certain delay is needed before executing the following command), **m** in minutes, **h** in hours, **d** in days\\ ''​$ sleep 10 && echo "10 seconds have passed."''​ |
-| **at** <​time>​ (<​date>​) (<​additional_time_specification>​) <​command>​ | executes a job at a specified time, **-f** <​file>​ reads commands from a specified file, **-c** <​job_number>​ displays the contents of the scheduled job, **-d** identical to „atrm“ command, **-l** identical to „atq“ command, **-m** send a mail to the user when the job has completed\\ ''​$ at 20:00 25.06.2007''​ / ''​at 7am today + 3 weeks **<​-'​**''​\\ ''​at>​ mail root < offer.txt **<​-'​**''​\\ ''​at>​ **ctrl**+**d**''​\\ ''​$ echo "date > date.txt"​ | at noon Sunday''​\\ ''​$ at -mf list 20:00 25.06.2007''​ |+| **at** <​time>​ (<​date>​) (<​additional_time_specification>​) <​command>​ | executes a job at a specified time, **-f** <​file>​ reads commands from a specified file, **-c** <​job_number>​ displays the contents of the scheduled job, **-d** identical to „atrm“ command, **-l** identical to „atq“ command, **-m** send a mail to the user when the job has completed\\ ''​$ at 20:00 25.06.2007''​ / ''​at 7am today + 3 weeks **<​-'​**''​\\ ''​at>​ mail root < offer.txt **<​-'​**''​\\ ''​at>​ **Ctrl**+**d**''​\\ ''​$ echo "date > date.txt"​ | at noon Sunday''​\\ ''​$ at -mf list 20:00 25.06.2007''​ |
 | **atq** / **at -l** | prints a list of scheduled jobs (a job number, time of execution, a user who scheduled the job) | | **atq** / **at -l** | prints a list of scheduled jobs (a job number, time of execution, a user who scheduled the job) |
 | **atrm** / **at -d** <​job_number>​ | cancels a scheduled job | | **atrm** / **at -d** <​job_number>​ | cancels a scheduled job |