I'm trying to find a way to execute a function (send some emails), 2 days after a new table is inserted into the database. I would like to do this without cron if possible, so I was wondering if is too wrong to use the sleep function, with 2 days time? Or any other suggestion..
Asked
Active
Viewed 193 times
1
-
3*"I would like to do this without cron if possible"* - Why? – ʰᵈˑ Oct 07 '16 at 15:51
-
Why not cron? Also, I'm curious: What needs to be done two days after a table insert? – Tomalak Oct 07 '16 at 15:52
-
If you even attempted this you'd have to set the PHP timeout limit stupidly high for it to keep running, which can lead to other issues. Plus then if you get a lot of table creations, you'll have loads of processes stacked up doing nothing for a couple of days. – gabe3886 Oct 07 '16 at 15:53
-
This is the first time I read something like this. The longest sleep I've seen a script doing was like a single minute. Two days!! Holy, one does not simply sleep two days. You can't do this. PHP will never wake up from that state. – Daniel W. Oct 07 '16 at 15:53
-
`sleep()` for 2 days will lock a worker for nothing and will certainly timeout (and reinvent the CRON wheel). "No cron" because the hosting service don't provide these? Then change for a better one. – Xenos Oct 07 '16 at 16:00
-
Use a free cron-http-ping service (Google for free cron). – Daniel W. Oct 07 '16 at 16:06
1 Answers
0
You can use SCHEDULE to set schedule for database query.
Maybe this question is already solved here

Community
- 1
- 1

Sumon Sarker
- 2,707
- 1
- 23
- 36