Shell script executes PHP command

 Shell  PHP 
the shell script is as follows
   cro_file=$dir_or_file"/crontab_php"
    -sharp
   if [ -f $cro_file ]
   then
      -sharp cat 
       cat $cro_file
   else
      echo "$cro_file not found."
   fi
crontab_php content format (using Tp5 framework structure)
-sharp 
-sharp 
application\index\index\index.php


actually execute the command
 php  application\\index\\index\\index.php
 -sharp
 -sharp

has two problems:

  1. do all scheduled tasks have to be written separately?
  2. how can I directly perform the scheduled tasks written in the framework without going to http?
Mar.03,2021

the so-called web framework is a http request framework. No matter how lightweight the framework is, it will also include routing, MVC, html templates
and other functions. When it comes to the framework of php, it faces a session.
so as I understand it, scheduled tasks cannot be written in the framework: which layer are you going to write on? Written in Controller? You still have to simulate a request. Simulation requests can cause trouble for load balancing, reverse proxy, cron log viewing, etc. Instead of asking for trouble, start another project.
cron tasks can be written in a separate project, not associated with the http request framework. For example, it is called the php_cron project, which is maintained according to a simple script. If there is a need to connect to the database and other resources, unify include into a special php file, such as mysql_connect.php. This is equivalent to maintaining several public php files separately in this project. This is much less performance than hard simulation of a request to walk the framework, and is much clearer. For smaller projects, this is sufficient. Larger projects need to consider managing scheduled tasks.
in addition, why do cron scheduled tasks require user login authentication? Why do specific users log in to the scheduled tasks within the system? Even in order to manage permissions by role, you should set specific permissions on the database and feel that they should not be combined with the login system.


tp can write a cli entry, suppose it is cli.php, and then you can execute php cli.php controller / method .


1. Additional write entries for scheduled tasks are easy to manage.
2. If PHP uses the frame, it unifies the entry file. You can write a new entry file with the frame. You can define $_ GET in this entry file so that you can directly locate the corresponding method

.
Menu