Is it possible to make a PHP script run automatically once a day? I have not full access to the webserver, it's a webhotell.

Any ideas?

/Andreas

    If you have a database, you could always visit your site once a day, and do something like this:

    MySQL.....

    Table = Jobs

    JobID (mediumint) primarykey
    TimeStamp (DateTime)
    File (varchar) 255

    php..... using whatever functions you have this sort of jist:

    db_query("SELECT * FROM Jobs WHERE JobID = the job you want to run AND (TO_DAYS(NOW()) - TO_DAYS(TimeStamp) < 1")

    if db_numberofresults < 1 {
    db_nextrecord
    file = db_field("File")
    include(file)
    } else {
    has been run, carry on!
    }

    TO_DAYS is an inbuilt mysql function. Subtract NOW() - todays date - from the database date, if it was run yesterday, it will return 1, if it was run today, it will not.

    Put this on your index page, and people will run jobs for you just by visiting your site.

      If you have telnet access you should still be able to run a cron job. If you have, telnet it and try

      man cron
      or
      man crontab

      Stephen's idea is also a good one, and as far as I can see the only option if you dont have telnet access.

      John

        Thank you for your ideas.

        I gave it a little thought and what I want to do is this. Every night I get a file mailed to me, this file I want to upload to my webserver and run a PHP script on it, that loads it into a MySQL database.

        The ideal here would be some kind of program running on my computer that could sense when the mail has arrived (we run a MS exchange mailserver), extract the file and upload it to my webserver and execute a PHP script.
        Is there such a program for Win32?

        Thanks!
        Andreas

          You have two problems here really. The first is to extract the attachment from the e-mail. If you are using outlook then I think you could write an in-box rule to extract attachments. There are probably options on MS-Exchange also to do similar.

          The next bit is to send the file to the server. This can probably be done using the wget command. wget is a unix command, but is available for windows. It runs from the command line and basically all it does is request a html file from a server on the internet. You could use this to make a call to a php script which has been designed for uploading and processing your file. The wget might look somehing like this

          wget http://www.yourdomain.com/upload.php?file=c:\temp\attachment.txt

          Does this make any sence?

          Good Luck
          John

            Just one last idea. If you cant use wget to upload files, you can always ftp the file and then use wget to call a script to process it.

              Write a Reply...