Jump to content

cron jobs


gardan06

Recommended Posts

i'm making a cron job in which i have to send an email subscription to numerous email addresses automatically, but the problem is cPanel's Cron Job function needs one specific email per cron job.

how can i make a cron job in which it will send a subscription to the emails saved in the database once a day?
Link to comment
Share on other sites

Just setup a PHP script to grab the emails and process them.  Then make the cron job call that script instead of whatever you're using to mail right now.

I'm not sure if you had thought of that or not... your post is a little vague on how you're actually doing the mailing currently.
Link to comment
Share on other sites

i think i get what ur saying, and that's what i kinda did actually. i created php file named emailsub.php in which it gets the email list for this day and send email subscriptions to each.

my problem is how will i call that php file? can i call the cron job thru cPanel? i haven't done any cron jobs before so im kind of a newbie on the subject.
Link to comment
Share on other sites

cron jobs are 'automated' meaning that they dont need you to manually execute your php file.  You set date and time under the cron job that you want the php file to execute.  The email address you specify for the cron job is just for output of the php file.  If for instance in your case you wanted to know what email addresses were sent a subscription you could 'echo' out each email address.  The echo information or any output would be in the email sent to the address specified for the cron job.
Link to comment
Share on other sites

your CRON job command actually needs to be the command line version of what you would call if you were running it manually. so, since you're running a PHP file, your CRON job command should look something like this:

[b]php /path/to/file/emailsub.php[/b]

now, the fun part is that some hosts have PHP installed in different locations for shared servers, so you may need to find out the path to PHP in order to call it.
Link to comment
Share on other sites

[quote author=gardan06 link=topic=109700.msg442734#msg442734 date=1159397186]
cool, thanks. i'll try it once my boss arrives. thanks a bunch!
[/quote]

if you're doing it from the command line, as suggested, using crontab, you'll need to set up your timing, too. for instance, if you want it to run once a day at midnight, you'd type this for your line on your crontab:

[code]
0 0 * * * php /path/to/file/emailsub.php
[/code]

read up a little more on what the first 5 parameters do.
Link to comment
Share on other sites

actually, there's no mention on this page to SSL manager except in your latest post. we referred to SHELL access which would be obtained through a client such as SSH or Putty. once you have logged into your account via one of those clients and you have shell access, then you can type in crontab -e
Link to comment
Share on other sites

have you logged in to your server? do you have a command prompt where you can type in shell commands? if so, just type "crontab -e" and you should be brought into your VI editor. type "i" to enter insert mode, and you can create your CRON job on your first line. once you're done, just hit "Esc" to exit insert mode and type ":wq" to save your job and exit. then, just wait for it to run. you may want to have some sort of log as part of your script to check whether or not it's actually running, though
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.