What is the code to call a cron job from php?

≡放荡痞女 提交于 2020-01-25 10:06:06

问题


I would like to call a cron job from within a PHP script. I am assuming this is the correct and most efficient solution to my problem.

Background:

I want to run a script that uses a user's inputted password before I store it in the database with 1 way encryption.

I also want to make sure the entire script runs even if the user leaves my site.

There are either two possibilities.
1.) Create a two way encrypted password that I can run later in the evening through cron (probably not secure, but any suggestions would be appreciated).

2.) Create a cron job on the fly using PHP to use the user's password before I store it in 1 way encryption.

Assuming #1 is not possible (or not secure), how would I call a cron job on the fly using php? If this isn't the only solution, how can i run a PHP file that will finish running if the user leaves my page?


回答1:


You don't want to start a CRON job, but a background command. Execute a shell from PHP, and pass it a command like this:

bash -c 'mycommand & exit';


来源:https://stackoverflow.com/questions/4918982/what-is-the-code-to-call-a-cron-job-from-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!