Linux Cron scheduled execution of PHP code with parameters

Linux Cron scheduled execution of PHP code with parameters

1. Still use PHP script to execute.

Command line fill in:

php /home/jb51.net/public_html/cron.php q1 q2

Then, in the cron.php page, use $argv[1] to get the value of the first parameter q1, and $argv[2] to get the value of the second parameter q2; the value of $argv[0] is the path and file name, which is: /home/jb51.net/public_html/cron.php

Second, use the wget command.

wget: A non-interactive network file grabbing tool under Linux.

Fill in the command line:

wget -d https://www.jb51.net/cron1.php?q1=11\&q2=22

Notice:

wget usage: wget [options] [URL]
Options: -d, --debug displays error output, i.e. debug mode; -q, --quiet quiet mode (do not input any messages).
When you use the -d parameter, the cron scheduled task will still send you debugging information emails. When you use the -q parameter, the system will not send you cron execution status emails. If you want the silent approach, you can use:

wget -q https://www.jb51.net/cron1.php?q1=11\&q2=22

When the wget method passes multiple parameters in the URL, the & symbol needs to be escaped, that is, \&; in addition, the absolute path URL needs to be used.

Third, you can try using curl

The command is:

/usr/bin/curl 'https://www.jb51.net/cron1.php?q=11&b=22' > /dev/null
or
curl --silent --compressed https://www.jb51.net/cron.php?q=1

Note: Piaoyi tried it and the first command was not executed successfully under hostmonster's cron; the second command was executed successfully under the ixwebhosting host.

This is the end of this article about Linux Cron scheduled execution of PHP code with parameters. For more relevant Cron scheduled execution of PHP content, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Ideas and codes for timing page generation in asp and php
  • Linux server configuration PHP file download, Chinese garbled characters, how to solve download errors
  • How to solve the problem of uploading large files in pieces using PHP
  • Solution to the problem of a large number of php-cgi.exe processes on the server causing the CPU to occupy 100%
  • Install PHP7.3 version under Linux system
  • PHP Local Outlier Factor Algorithm - Specific Implementation Analysis of Local Outlier Factor (LOF) Algorithm

<<:  HTML displays ellipsis beyond the text... implemented through text-overflow

>>:  CSS to implement QQ browser functions

Recommend

Tutorial on installing Ubuntu 20.04 and NVIDIA drivers

Install Ubuntu 20.04 Install NVIDIA drivers Confi...

Introduction to Docker containers

Docker Overview Docker is an open source software...

Detailed explanation of Nginx Rewrite usage scenarios and code examples

Nginx Rewrite usage scenarios 1. URL address jump...

Web data storage: Cookie, UserData, SessionStorage, WebSqlDatabase

Cookie It is a standard way to save the state of ...

Vue's Render function

Table of contents 1. Nodes, trees, and virtual DO...

How to avoid data loop conflicts when MySQL is configured with dual masters

I wonder if you have ever thought about this ques...

React+Antd implements an example of adding, deleting and modifying tables

Table of contents Table/index.js Table/model/inde...

HTML table markup tutorial (37): background image attribute BACKGROUND

Set the background image for the table header. Yo...

Detailed explanation of how to install MariaDB 10.2.4 on CentOS7

CentOS 6 and earlier versions provide MySQL serve...

CentOS 7.5 deploys Varnish cache server function

1. Introduction to Varnish Varnish is a high-perf...

Detailed example of removing duplicate data in MySQL

Detailed example of removing duplicate data in My...

How to implement navigation function in WeChat Mini Program

1. Rendering2. Operation steps 1. Apply for Tence...