〇 There is a process that I want to run to get up.
I searched for a way to configure cron on EC2 and tried using crontab, but it doesn't work. ..
I'm at a loss because I don't know if the description of crontab is wrong or if crontab itself is wrong.
I am glad if you could tell me.
[When executing the process of /home/ec2-user/html/cron/test.php every minute]
▼ I did the following.
① At the SSH terminal
② In crontab
* /1 * * * /usr/bin/php /home/ec2-user/html/cron/test.phpAdd and save
But the process is not executed ...
I would appreciate it if you could teach me.
Answer # 1
/ etc/crontabIs run with root privileges and is usually used when you want to run system jobs on a regular basis.
There is no reason to use it this time for the purpose.
Edit the crontab of the user who wants to execute the file and set it there.
However, it should still be executed (since it has root privileges, there is no lack of privileges), but it is not executed because the cron notation format is incorrect.
*/1 * * *
If you want to run every hour
* */1 * * *Is the correct way to write.
And personallyWe do not recommend using the crontab command to edit cron settings..
crontab -eSo you can certainly edit the current user's cron settings,
At that time
crontab -rIf you hit the wrongThe cron settings disappear..
There is no particular confirmation, and the setting will be empty in one shot..
This is very risky as e and r are next to each other on QWERTY keyboards.
So, explicitly using vim etc.
/ var/spool/cronI recommend the method of editing the cron settings of the corresponding user under it.
If you want to edit the cron configuration file of ec2-user, you can do as follows, for example.
Answer # 2
① Type $sudo vi/etc/crontab in the SSH terminal
The file to be set is incorrect.
Set cron with the privileges of the user you want to run.
If you set with ec2-user
crontab -eLet's edit and set with.
* There is no need to directly tamper with/var/spool.
② Add */1 * * * /usr/bin/php /home/ec2-user/html/cron/test.php to crontab and save
There is a mistake in specifying the execution time. Unlike the first one, this one is easier to search and find, so please check it again.
Answer # 3
Try to access it on an http basis with a crawler such as wget or curl
- php - i want to set the judgment of 0 to true in empty
- php - i want to insert data from multiple tbls into one tbl
- php: i want to add a control number to each date
- i want you to see the error contents of php
- php - i want to be able to use the validate function
- i want to pass the php path
- i want to be able to describe it in [php] functionphp
- i want to get the name of the laravel php zip file
- i want to set 404 in firebase hosting
- ruby on rails - i want to set responsestatus to 200, but it becomes 401
- i want to implement a php mail form
- php - i want to pass the image file to the server
- php - i want to open the same page on one side and another tab on the other side in the html form
- php - i want to pass music data from db to tag
- php - i don't want to use foreach! !! !!
- i want to delete all db table data from php
- i want to run cron at random times
- i want to have date information in php link parameters
- i want to store js variables in php in the same file