waiting on exec()

Discussion in 'PHP' started by bandito40, Mar 27, 2008.

  1. #1
    Hi,

    I have been trying to find a way to delete a file about 30 minutes after it is created by a php script. I came up with the idea to use exec() to give the following linux command "sleep 1200 && php delete.php". Ofcourse you have to download and install the module php5-cli for this to work. The problem I am getting in that php sits and waits until the sleep command lets php run the delete.php script. Is there a way that php can give a system command and not have to wait for it finish?


    Thanks,

    Carl


    http://www.gaihosa.com
     
    bandito40, Mar 27, 2008 IP
  2. Weirfire

    Weirfire Language Translation Company

    Messages:
    6,979
    Likes Received:
    365
    Best Answers:
    0
    Trophy Points:
    280
    #2
    Hi Carl,


    Why not set up a cron job to run a file every 15 minutes which will check if there are any items in your database which you want to remove?



     
    Weirfire, Mar 27, 2008 IP
  3. Morishani

    Morishani Peon

    Messages:
    239
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #3
    There is a way to achieve what he want's without cron jobs,
    To write the timestamp for the time he want's the file to be deleted somewhere (database etc').

    And then to check in every connection to the relevant page if the timestamp that has been written in the database has past, if it has past then delete the file, if not then not :)

    hope it's clear enough.

    Good luck.
     
    Morishani, Mar 27, 2008 IP