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

Uncommon but useful tags in Xhtml

Xhtml has many tags that are not commonly used but...

Key knowledge summary of Vue development guide

Table of contents Overview 0. JavaScript and Web ...

Detailed explanation of simple snow effect example using JS

Table of contents Preface Main implementation cod...

React-native sample code to implement the shopping cart sliding deletion effect

Basically all e-commerce projects have the functi...

How to package the project into docker through idea

Many friends have always wanted to know how to ru...

How to install and deploy gitlab server on centos7

I am using centos 7 64bit system here. I have tri...

How to install PHP7.4 and Nginx on Centos

Prepare 1. Download the required installation pac...

WeChat applet implements a simple calculator

A simple calculator written in WeChat applet for ...

Linux IO multiplexing epoll network programming

Preface This chapter uses basic Linux functions a...

How to build a tomcat image based on Dockerfile

Dockerfile is a file used to build a docker image...

Take you to a thorough understanding of the prototype object in JavaScript

Table of contents 1. What is a prototype? 1.1 Fun...

Linux process management tool supervisor installation and configuration tutorial

Environment: CentOS 7 Official documentation: htt...