Ubuntu command, no that file or directory

Running linux_server, if ubuntu   Prompt: the following installation commands can be executed without this software

sudo apt-get -y install lib32z1

sudo apt-get -y install lib32stdc++6

If the above command cannot find the installation package, you can use the following command to find the package name and find a similar download

apt-cache search lib32stdc++

Install process monitoring tool htop

apt-get -y install htop

Install the network monitoring tool wireshark

apt-get -y install wireshark

Kill process by process name

1. pkill   Process name

two   killall   Process name

three   kill -9 $(pidof process name)

ubuntu   Planning tasks

Windows comes with a tool to execute tasks regularly, which is called "scheduled tasks". Under Linux, we use Cron to realize this function.

one   install

$ apt-get install cron

If installed, enter the following command to determine whether the cron service is started:

$ pgrep cron

If there is a pid (a string of numbers) output, it indicates that the cron service has been started. If there is no output, it indicates that the cron service needs to be started manually.

Start cron service:

$ service cron start

Manage task plan files

All task plans of cron are recorded in the crontab task plan file, which is managed through the crontab command.

usage: crontab [-u user] file
       crontab [ -u user] [ -i ] { -e | -l | -r }
               (default operation is replace, per 1003.2)
       -e      (edit user's crontab)
       -l      (list user's crontab)
       -r      (delete user's crontab)
       -i      (prompt before deleting user's crontab)

Parameter Description:
-u user specifies the user
-e edit the planned task file of a user. If no user is specified, the planned task file of the current user will be edited by default
-l displays the planned task file of a user. If no user is specified, the planned task file of the current user is displayed by default
-r delete the planned task file of a user. If no user is specified, the planned task file of the current user will be deleted by default
-i push confirmation prompt before deletion

Use example:

$ crontab -u foo -e     #Edit user foo's scheduled task file

$ crontab -e            #Edit the current user's scheduled task file

$ crontab -u foo -l     #Displays the user foo's scheduled task file

$ crontab -l            #Displays the current user's scheduled task file

$ crontab -r            #Delete the current user's scheduled task file

Edit task schedule file

When using crontab -e for the first time, you may need to select the editor, enter the editor serial number, and click enter to enter the planned task file editing mode. If you directly enter the editing mode, ignore the above contents.

After entering the editing mode, add the task plan according to the specified format.

The syntax format of the task plan is as follows:

m h dom mon dow   command
0-59 0-23 1-31 1-12 0-7  command
  • m: Represents minutes
  • h: Indicates hours
  • dom: represents the date
  • mon: month
  • dow: indicates week
  • Command: pre executed command

In addition, some special symbols need to be used to realize flexible configuration:

  • *Represents all values
  • /Stands for "every"
  • -Scope of representation
  • , split number

Examples of tasks are as follows:

## Specify specific execution time
2   *  *  *  * ls    #Execute the ls command every second minute of the hour
30  7  *  *  * ls    #Execute the ls command at 7:30 every day
30 20  *  *  2 ls    #Execute ls command every Tuesday at 20:30 (0 and 7 indicate Sunday)

## Specify the interval
*/2 *  *  *  * ls    #Execute the ls command every 2 minutes

## Specify time period
30  7 3-6 *  * ls    #Execute the ls command at 7:30 on the 3rd, 4th, 5th and 6th of each month

## Specify multiple times
30  7 3,6 *  * ls    #Execute the ls command at 7:30 on the 3rd and 6th of each month

In addition, run parts can be used to run all scripts in the specified directory (note that the script must add "#! / bin/bash", otherwise the run parts call will fail)

30 7 * * * run-parts /home   #Run all scripts in the / home directory at 7:30 every day

Add a task according to the specified format. After saving, the task will take effect.

The following is an actual scheduled task file, including the comments provided by the system and a scheduled task that executes the output string "Hello World" to the cron_test file in the / home directory every two minutes.

# Edit this file to introduce tasks to be run by cron. 
# 
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
# 
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').# 
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
# 
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
# 
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
# 
# For more information see the manual pages of crontab(5) and cron(8)
# 
# m h  dom mon dow   command
*/2 * * * * echo "Hello World" >> /home/cron_test

Tags: Linux Ubuntu vim

Posted on Sat, 09 Oct 2021 05:48:07 -0400 by RCB