473,672 Members | 2,881 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using PHP for nightly backend tasks?

I have to develop a script to be run nightly to go through a database
and send emails based on conditions. It's a large database, and there
are several thousands of emails to be sent during the week everyday.
The script will be run with a cron job at midnight or so.

I was wondering if PHP is suitable for this, or may it be problematic,
for instance would its execution abort after a certain amount of time?
Or is it perfectly fine for this task?
Thanks.

Jul 17 '07 #1
4 2237
>I have to develop a script to be run nightly to go through a database
>and send emails based on conditions. It's a large database, and there
are several thousands of emails to be sent during the week everyday.
The script will be run with a cron job at midnight or so.

I was wondering if PHP is suitable for this, or may it be problematic,
for instance would its execution abort after a certain amount of time?
Or is it perfectly fine for this task?
You may want command-line PHP for this task. The interface is a
little different (e.g. no $_GET and $_POST) but you can set different
parameters and I believe the run time limit defaults to infinite.
Anyway, the parameters can be put in a different .ini file and set
differently than for web-based PHP.

Jul 17 '07 #2
C.
On 18 Jul, 00:09, gordonb.h6...@b urditt.org (Gordon Burditt) wrote:
I have to develop a script to be run nightly to go through a database
and send emails based on conditions. It's a large database, and there
are several thousands of emails to be sent during the week everyday.
The script will be run with a cron job at midnight or so.
I was wondering if PHP is suitable for this, or may it be problematic,
for instance would its execution abort after a certain amount of time?
Or is it perfectly fine for this task?

You may want command-line PHP for this task. The interface is a
little different (e.g. no $_GET and $_POST) but you can set different
parameters and I believe the run time limit defaults to infinite.
Anyway, the parameters can be put in a different .ini file and set
differently than for web-based PHP.

You can set the time limit at run time. Also, while using the CLI PHP
(which cames as standard with the SAPI module in most Linux distros)
is the prefered option, you can invoke a web page using the wget
command (or curl) - but, in addition to to getting your webserver to
maintain a very long connection, you would need to expose the relevant
script via the web interface.

To run the php script from the command line...

php -q /some/where/mysrcipt.php

or insert the path to the command processor as the first line of your
script and make it executable:

#!/usr/bin/php5
<php>
.....

chmod ug+x /some/where/mysrcipt.php

C.

Jul 19 '07 #3
On Jul 18, 1:09 am, gordonb.h6...@b urditt.org (Gordon Burditt) wrote:
I have to develop a script to be run nightly to go through a database
and send emails based on conditions. It's a large database, and there
are several thousands of emails to be sent during the week everyday.
The script will be run with a cron job at midnight or so.
I was wondering if PHP is suitable for this, or may it be problematic,
for instance would its execution abort after a certain amount of time?
Or is it perfectly fine for this task?

You may want command-line PHP for this task. The interface is a
little different (e.g. no $_GET and $_POST) but you can set different
parameters and I believe the run time limit defaults to infinite.
Anyway, the parameters can be put in a different .ini file and set
differently than for web-based PHP.

I'd rather use set_time_limit( ) if php is not running in safe mode.
I just want to mention that if you plan to send a personalised content
for each contat, you may want to use an temporary table where, at the
begining of the mailing process you want to implement, you prepare
your data (associate mail adress and other contact stuff with suitable
content) using php, then launch an other script tha just grab data
from this temporary table and send it, this will considerably minimise
exectime and load on your server ..
Adding a sent/not_sent flag to this temp table would let you resume
sending mails if some things goes wrong with your smtp for example ..

Jul 19 '07 #4
NC
On Jul 17, 3:04 pm, Charles <landema...@gma il.comwrote:
>
I have to develop a script to be run nightly to go through
a database and send emails based on conditions. It's a large
database, and there are several thousands of emails to be
sent during the week everyday. The script will be run with
a cron job at midnight or so.

I was wondering if PHP is suitable for this
Absolutely, as long as you have a command-line interpreter on your
system. With PHP is executed from the command line, timeouts do not
apply; the script behaves as any other shell script would.

Cheers,
NC

Jul 20 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
3156
by: Scott | last post by:
Hi, Can I ask some advice in regards database solutions and content management solutions.? Do you have a philosophy on what is the best for databases - ASP, JSP, Cold fusion, PHP, etc. My company website site is going to be rebuilt and I am the lucky one to do this but I am unsure of the needs and complexity of the project, and what would be the best base code. Do you have any thoughts in this area? The site requires functionality...
9
2187
by: DW | last post by:
Greetings: I have a SQL 2000 server with several databases on it, and I have a maintenance plan that includes both a backup and a CHECKDB Integrity Check. The backups appear to run correctly each night, but if a user leaves a connection open to a database all night, the CHECKDB fails. I'd like to be able to kill all client connections before each backup
15
3781
by: bugzilla | last post by:
hi,all, I have a C++ program need to convert to c language to be used in a emabedded system. the problem is that the original code was writtern in C++ language with Parent class and some child class. How can I invert these C++ code into pure c code by using struct in C language? Can somebody give me any ideas? thanks. For example, how to conver the following code into pure c code?
7
1579
by: Rick | last post by:
I'm sorry for posting this here, but other more relevant groups are a little too quiet. Has anyone out there come up with an effective strategy for using VSS with a development team? IME it is a nightmare trying to manage releases of code. We need one release to share among developers, one for the QA team, and one for the live application. The problem is, VSS really only has one version at any one time. I'm guessing that VS2005 Team...
18
1969
by: rdemyan via AccessMonster.com | last post by:
Here's my plan for creating nightly backups of the production back-end file (the IT staff in their infinite wisdom have prevented use of Windows Scheduler and users do not have administrative rights to Windows). Candace Tripp has an automatic backing up program that I modified for our use. You can schedule a time for the backup to occur. Since Windows task scheduler is not available to us, this means that the auto backup program will...
6
2778
by: arun.hallan | last post by:
Hi, I want to run a webservice method every night at a specified time, say 10pm. The current way i thought of doing this is to have a windows service and a timer which checks the time every minute and when it gets to 10:00 it fires off the webmethod. Is this the best way to do it? If not, does anyone have any
0
1495
by: jer006 | last post by:
Hi, This is more of a general question... I have a series of stored procedures (chain of procedures) in db2 on an AS400 which are executed from a SQL Server Job, when I execute the job manually during the day (or when I execute the stored procedures in db2 on the AS400 directly) everything completes successfully. However when the procedures are executed on its scheduled cycle at 3am in the morning it fails most every morning with a...
0
357
by: Charles | last post by:
I have to develop a script to be run nightly to go through a database and send emails based on conditions. It's a large database, and there are several thousands of emails to be sent during the week everyday. The script will be run with a cron job at midnight or so. I was wondering if PHP is suitable for this, or may it be problematic, for instance would its execution abort after a certain amount of time? Or is it perfectly fine for this...
5
2649
by: rcook349 | last post by:
I want to run a piece of C# code at midnight every night that opens a file, changes something in it, and saves it. Would this be a Console Application set up as some sort of job? Would it be a Windows Service? Thanks, Ron
0
8418
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8940
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8840
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8630
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8694
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4237
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4434
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2833
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1831
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.