A
A
Alexander Diunov2014-12-20 18:47:08
PHP
Alexander Diunov, 2014-12-20 18:47:08

How to set up a php script to run via cron (php-fpm)?

I have never dealt with cron. Help me please.
There is a server. There's php-fpm (php 5.5).
It is necessary to configure the launch of the php script via cron:
1. Every minute without sending the result to the mail
2. Every hour with sending the result to the mail
The path to the script is /server/cron/cron.php. I tried to google the instructions, nothing happened. I suspect that the problem is in the path to php (how can I find it?).
Explain popularly how to set up cron.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexander Diunov, 2014-12-20
@adiunov

Final decision
Install php5-cli
1.
Add a task to cron that will run every minute.
Collect crontab -eand add
save (I have SHIFT + Z 2 times)
> /dev/null- means sending the results that the script will give to nowhere.
2>&1- saves the server administrator from letters if the script finishes with errors
2.
to send to the mail, we use mutt (mail client)
add a task to cron that will be executed every hour (at zero minutes), save the result of the script execution to a file and send it to mail with the subject cron-result (in our case, in the body of the letter, but it can also be an attachment).
Collect crontab -eand add
save (I have SHIFT + Z 2 times)
Everything is ready.

V
Vladislav, 2014-12-20
@click0

You are confusing the use of php-fpm and php-cli
whereis php - it will show the path to php
even when you start cron, you need to specify the full paths to the programs and env will be different from your shell

F
FanatPHP, 2014-12-20
@FanatPHP

the one that once a minute is most likely not needed.
approximately 146% of noobs want to run cron once per minute. 100% of them don't need it.
To receive letters from cron in the crontab write
Error messages will be sent in the letters, if any occur.
These errors can be corrected.
Correcting real errors is much more effective than running blindfolded in a dark room and correcting everything that moves, as is customary among pohap users.
Yes, and before pushing your command into cron, you first need to test it in the console. Toee will save a lot of time.
Well, this is, of course, if there is a console, and not the Control Panel.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question