Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can a PHP script be run regularly on a server without requests from a client?

Tags:

php

mysql

pdf

I'll be writing a script to parse text documents into a MySQL database. I'll be converting PDF's to text with a separate utility. These PDF's will be submitted via e-mail attachments.

I'm looking to see if I can do this with PHP since that's the server language I'm most familiar with. Second choice would be Perl, but I'll take your recommendations.

So the language needs to be able to:

  1. Check an e-mail account for e-mails with attachments (every few minutes, or so).
  2. Save the attachment.
  3. Parse the file (looking for contact information) using Regular Expressions.
  4. And place the results in a MySQL Database

I won't have full access to the server since it'll be hosted by GoDaddy or similar.

I'm familiar with PHP but I can't think of how I'd have it systematically check a mailbox. If PHP can't do it, are there languages that run constantly on a server performing tasks without requests from a browser?

Thank You.

like image 369
Andrew Avatar asked Dec 02 '22 06:12

Andrew


2 Answers

You can do it with a PHP script, managed via a cron job.

like image 126
Sampson Avatar answered Dec 04 '22 20:12

Sampson


You can trigger the HTTP requests regularly using a service like http://www.setcronjob.com/

like image 20
funwhilelost Avatar answered Dec 04 '22 20:12

funwhilelost