Jump to content

Archived

This topic is now archived and is closed to further replies.

gardan06

cron jobs

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?

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites
you need to have secure shell access to your webserver.  After logging in you would type crontab -e. You could then setup a cron job with the command posted my obsidian

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
You guys told me that i should type crontab -e on the SSL Manager, but where among those 3 should i type it in? Manage SSH Keys, Connect using SSHTerm, or Connect using Java Telnet Applet.?

Share this post


Link to post
Share on other sites
i do have shell access now, that's the one saying "SSH/Shell Access", right? what do i do next?

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
i used Java Telnet Applet, types "crontab -e" there, and it returned a message "wrote 2 lines". im not sure if it worked though. how can i check if it did?

Share this post


Link to post
Share on other sites

×

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.