Tips for using timed commands in Linux systems

  
                

For beginners, Linux system commands are the main learning content. In many Linux commands, some commands can be run periodically. The following small series will give you a detailed introduction to the usage of the timed running commands in Linux. Let's go.

1. Introduction
command

Each user has a different task list program with their own login account to run

code is as follows:

crontab -l

You can view the scheduled tasks of each task. You can modify your own scheduled tasks by using the following commands.

The code is as follows:

crontab -e

After each task is added, you must remember to restart the crond service, otherwise it will not take effect

The code is as follows:

service crond restart

2. Examples

Below is a sample of a scheduled task

The code is as follows:

#4 of every month and every week of the week 1 to Wednesday 11 Point

0 11 4 * mon-wed date

The above sentence means “<4 every month and every week from Monday to Wednesday at 11:00 am Time & rdquo;, you change the date to the command you want to execute, and then change the execution time, you can form a timed execution command

code Bottom:

#Execute once per minute

*/1 * * * * date

#Write a shell script under /root/run_sh/and name it run. Sh, the content is as follows

#! /bin/sh

echo hello 》 /root/Hello.txt

Then run the crontab -e command and write the

code as follows:

* /1 * * * * /root/run_sh/run.sh (must be absolutely path)

After saving and exiting, execute service crond restart. After one minute, you will see Hello.txt under /root. file.
Previous123Next page Total 3 pages

Copyright © Windows knowledge All Rights Reserved