Apple cms scheduled task Crontab sets Apple cms automatic update script

How to use the Crontab command to set the automatic update of scheduled tasks in Apple cms

There are several ways to update the scheduled task of Apple CMS. If the Apple CMS is built in Windows, you can use the scheduled update task that comes with Windows. If it is a Linux operating system, you can set the scheduled update task on a third-party platform, or Set custom update tasks on third-party websites such as Alibaba Cloud and Tencent Cloud. The following introduces another way to use the crontab command to set up scheduled tasks to automatically update the website in the Linux system..

Understand what crontab scheduled tasks are

Through the crontab command, we can execute specified system commands or shell scripts at fixed intervals. The unit of time interval can be minutes, hours, days, months, weeks, or any combination of above. This command is very suitable for periodic log analysis or data backup.

Command format

crontab [-u user] file crontab [-u user] [ -e | -l | -r ]

Command parameters

-u user: used to set the crontab service of a certain user;
file: file is the name of the command file, which means that file is used as the task list file of crontab and loaded into crontab. If this file is not specified on the command line, the crontab command will accept commands typed on standard input (keyboard) and load them into crontab.
-e: Edit the contents of a user's crontab file. If no user is specified, it means editing the crontab file of the current user.
-l: Display the contents of a certain user's crontab file. If no user is specified, it means displaying the contents of the current user's crontab file.
-r: Delete a user's crontab file from the /var/spool/cron directory. If no user is specified, the current user's crontab file will be deleted by default.
-i: Give a confirmation prompt when deleting the user's crontab file.

crontab file format

Commands to be run on time, day, month and week

  • Column 1 minutes 0 to 59
  • Hours 0 to 23 in column 2 (0 means midnight)
  • 3rd column day 1~31
  • Column 4, months 1 to 12
  • Column 5: Day of the week 0 to 7 (0 and 7 represent Sunday)
  • The command to run in column 6
# .------------- minutes, the value range is 0-59 # | .------------- hours, the value range is 0 -23 # | | .---------- day, value range is 1-31 # | | | .------- month, value range is 1-12 # | | | | .---- Day of the week, the value range is 0-7, 0 and 7 both represent Sunday # | | | | | .-- The command to be executed # | | | | | | 0 19 * * * bash /root /

Apple cms scheduled tasks

Next, configure the scheduled tasks of Apple CMS. First, in the background of Apple CMSsystemProceed in the optionsScheduled task configuration.

苹果cms定时任务 Crontab设置苹果cms自动更新脚本

In the operation options behind the task that needs to be automatically updated, intestRight-click on the mouse and clickCopy link addressObtaintestURL address.

For example: https:// api.php/timming/index.html?enforce=1&name=gs

These URLs are opened in the browser and need to be valid links that can update the website normally.

Next, set up a scheduled task in the Linux system.

Install crontab

一般 CentOS 会默认安装了 crontab,执行下面命令,查看是否安装:

rpm -qa | grep crontab

If the query results are similar to the following, it means it has been installed:

苹果cms定时任务 Crontab设置苹果cms自动更新脚本

If the result is empty, it means it is not installed. Just execute the following command to install it:

dnf install -y crontabs

crontab common commands

Check the crontab running status:

systemctl status crond

As shown in the figure above, if the displayed result is Active: active (running), it means it is running, and Active: inactive (dead) means it is not running.

If crontab is not running, you can use the following commands to set up auto-start and startup.

Set crontab to start automatically at boot:

systemctl enablecrond

Start crontab:

systemctl start crond

View the current user’s scheduled tasks:

crontab -l

Set up scheduled tasks

First create a script in the root directory.

vi /root/

Press i to enter editing mode and paste the following content:

#! /bin/bash a=$(curl -k '') b=$(curl -k 'https:/ /') c=$(curl -k ' 1&name=xl') d=$(curl -k '') e=$(curl -k 'https://') echo $a sleep 10 echo $b sleep 10 echo $c sleep 10 echo $d sleep 10 echo $e

Press the Esc key and enter:wq to save the file.

You can also use the following writing method, the effect is the same.

#!/bin/bash func() { curl '' touch gs echo "gs opened" } func & sleep 5 if [ -f gs ] then echo "gs succeeded" else echo "gs failed" fi rm -f gs sleep 10 func() { curl '' touch kc echo "kc opened" } func & sleep 5 if [ -f kc ] then echo "kc succeeded" else echo "kc failed" fi rm -f kc sleep 10 func() { curl '' touch sd echo "sd opened" } func & sleep 5 if [ -f sd ] then echo "sd success" else echo "sd failure" fi rm -f sd sleep 10 func() { curl '' touch xl echo "xl opened" } func & sleep 5 if [ -f xl ] then echo "xl success" else echo "xl failed" fi rm -f xl sleep 10 func() { curl '' touch lz echo "lz opened" } func & sleep 10 if [ -f lz ] then echo "lz success" else echo "lz failed" fi rm -f lz

sleep command syntax The following is the syntax of sleep command in Bash:
sleep number[suffix]
You can use positive integers or decimals as time values. The suffix is an optional part. You can use any of the following as suffixes:

  • s – stands for seconds
  • m – represents minutes
  • h – hour
  • d – means day

Note: If there is no suffix, the number is in seconds (by default).

If two or more arguments are specified, the total time is considered equal to the sum of the values. Here are some simple examples demonstrating how to use the sleep command:

  • To sleep for 9 seconds, use:
    sleep 9 or sleep 9s
  • To sleep for 0.5 seconds, use:
    sleep 0.5 or sleep 0.5s
  • To sleep for 2 minutes and 30 seconds, use:
    sleep 2m 30s
  • To sleep for 8 hours, use:
    sleep 8h
  • Sleeping for 2 days, 9 hours, 5 minutes and 55 seconds, using:
    sleep 2d 9h 5m 55s

Execute the following command to edit the current user's scheduled tasks:

crontab -e

After executing the crontab -e command, a document will be opened. Press i to enter the editing state. Paste the following into the document. Then save and exit!

0 19 * * * bash /root/

The above code means that at 19:00 every day, the /root/ script is executed.

If you want to execute the script every hour, you can add it one by one.

Note: In the configuration file of the scheduled task, you cannot enter 24 for the time of 24 o'clock. You must enter 0, otherwise an error will be reported!

For example:

0 1 * * * bash /root/ 0 2 * * * bash /root/ 0 3 * * * bash /root/ 0 4 * * * bash /root/ 0 5 * * * bash /root/ 0 6 * * * bash /root/ 0 7 * * * bash /root/ 0 8 * * * bash /root/ 0 9 * * * bash /root/ 0 10 * * * bash /root/ 0 11 * * * bash /root/ 0 12 * * * bash /root/ 0 13 * * * bash /root/ 0 14 * * * bash /root/ 0 15 * * * bash /root/ 0 16 * * * bash /root/ 0 17 * * * bash /root / 0 18 * * * bash /root/ 0 19 * * * bash /root/ 0 20 * * * bash /root/ 0 21 * * * bash /root/vod .sh 0 22 * * * bash /root/ 0 23 * * * bash /root/ 0 0 * * * bash /root/

Problems related to crontab not executing

  • Check whether bash or /etc/profile;/bin/sh is added before the script path
  • Check whether the crontab service is normal
  • Check if script path is absolute path

The curl request URL contains & the request failed

In a curl request, when the URL contains multiple parameters, the URL needs to be enclosed in single quotes, otherwise the request will be truncated. Just use single quotes to enclose the content of the URL.

Three ways to open web pages from the command line in Ubuntu

The first method links command

apt install links links ''

The second method w3m command

apt install w3m w3m ''

The third method lynx command

apt install lynx lynx ''



5/5 - (1 vote)

Leave a Reply

Your email address will not be published. Required fields are marked *