Cron this command is installed and started by default


-The service program of crontab under Ubuntu is cron, and the default log of cron service is not available. We have to start it manually
-Command: sudo VIM / etc / rsyslog.d/50-default.conf
-Find the line cron. * and remove the comment, / var / log / cron. Log
-Restart cron service sudo service cron restart
Restart the service every time a new task is added
  • The command is as follows:

    • service cron start /Startup service/
    • service cron stop /Shut down service/
    • service cron restart / Restart service/
    • service cron reload /service crond reload /
  • View cron process

    • pgrep cron

      • Return process ID
  • crontab -u /Set the cron service for a user/
  • crontab -l /List the details of a user’s cron service/
  • crontab -r /Delete a user’s cron service/
  • crontab -e /Edit a user’s cron service/

    • Parameter implication
    • L shows the contents of the user’s crontab file example: crontab – L
    • I give an example before deleting the crontab file of the user: crontab – ri
    • R example of deleting a user’s crontab file from the crontab Directory: crontab – R
    • E example of editing a user’s crontab file: crontab – e
  • /The syntax of etc / crontab file is as follows:

    Minute  Hour  Day  Month  Dayofweek   user   command
    */1 * * Ubuntu CD / home / Ubuntu & & sh starts every minute
    *  0    * * *   ubuntu  cd /home/ubuntu && sh
- Minute  Hour  Day  Month  Dayofweek  command
-Minute: minute (0-59), indicating the minute of each hour to execute the task
-Hour: hour (1-23), indicating the hour of the day to perform the task
-Day: date (1-31), indicating the day of each month to perform the task
-Month: month (1-12), indicating the month of each year to perform the task
-DayOfWeek: Week (0-6, 0 stands for Sunday), indicating the day of the week to perform the task
-Command: specify the command to execute (if there are too many commands to execute, you can write them into a script, and then call the script directly here. Remember to write the complete path of the command when calling)
-"*", representing all numbers within the value range;
-"/", representing "every" ("* / 5", representing every 5 units);
-"-", representing from a number to a number ("1-4", representing 1-4 units);
-Separate several discrete numbers;

 The shell script contains the prompt source: not found
 If / bin / SH is displayed after: LS - L / bin / SH - > dash 
    Command line execution: dpkg reconfigure dash (root permission required) 
    Select no in the interface 
    Run LS - L / bin / sh again and then display / bin / SH - > Bash