Jump to content

Send email every 24 hours for every topic without using cron


abs0lut

Recommended Posts

If you don't like cron you could try this:

ignore_user_abort(true);
set_time_limit(0);

do
{
   //Code here
   sleep(86400); //24 hrs
}
while (true);

 

Not tested. I'm sure cron would be much more efficient though, of course I have no experience with it though.

Link to comment
Share on other sites

I have set up a cron task using the cron jobs application in cPanel, I indicated that everyday it should run the following task

http://domain.com/send.php

and I received this email

/bin/sh: http://domain.com/send.php: No such file or directory

could you please help me?

 

You need to actually run the script through the PHP binary.  The shell has no idea how to parse it.  And you don't use the URL of the file, you use the file path.  You'd probably use:

 

0 0 * * * /usr/bin/php /home/yourname/send.php

Link to comment
Share on other sites

One not all hosts allow that

Well would be good to get have one that does :P

 

and two he would have to have the script running all the time

When you use ignore_user_abort, it will still run even if the user closes out of the page (I believe). Also using sleep will have it rest for 24 hours to do it again.

 

Cron would be better to do though.

Link to comment
Share on other sites

Stephen's right, you can get a script to run 24/7, I made an uploader one time that ran 23.5 hours a day, and only restarted itself with cron to release it's memory and fix if it crashed - and it never crashed. All cron is is a program that runs all the time, there isn't much difference between it and having PHP do it.

 

I would start it with putty and background the process though - we have to do some weird stuff to keep it from dieing when the session was closed.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.