gardan06 Posted September 27, 2006 Share Posted September 27, 2006 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? Quote Link to comment https://forums.phpfreaks.com/topic/22247-cron-jobs/ Share on other sites More sharing options...
ober Posted September 27, 2006 Share Posted September 27, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/22247-cron-jobs/#findComment-99631 Share on other sites More sharing options...
gardan06 Posted September 27, 2006 Author Share Posted September 27, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/22247-cron-jobs/#findComment-99650 Share on other sites More sharing options...
Fehnris Posted September 27, 2006 Share Posted September 27, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/22247-cron-jobs/#findComment-99751 Share on other sites More sharing options...
obsidian Posted September 27, 2006 Share Posted September 27, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/22247-cron-jobs/#findComment-99755 Share on other sites More sharing options...
gardan06 Posted September 27, 2006 Author Share Posted September 27, 2006 ok cool. but where should i type "php /path/to/file/emailsub.php" though? Quote Link to comment https://forums.phpfreaks.com/topic/22247-cron-jobs/#findComment-99870 Share on other sites More sharing options...
gardan06 Posted September 27, 2006 Author Share Posted September 27, 2006 anyone? Quote Link to comment https://forums.phpfreaks.com/topic/22247-cron-jobs/#findComment-99904 Share on other sites More sharing options...
Fehnris Posted September 27, 2006 Share Posted September 27, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/22247-cron-jobs/#findComment-99908 Share on other sites More sharing options...
gardan06 Posted September 27, 2006 Author Share Posted September 27, 2006 cool, thanks. i'll try it once my boss arrives. thanks a bunch! Quote Link to comment https://forums.phpfreaks.com/topic/22247-cron-jobs/#findComment-99928 Share on other sites More sharing options...
obsidian Posted September 28, 2006 Share Posted September 28, 2006 [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. Quote Link to comment https://forums.phpfreaks.com/topic/22247-cron-jobs/#findComment-99984 Share on other sites More sharing options...
obsidian Posted October 2, 2006 Share Posted October 2, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/22247-cron-jobs/#findComment-102320 Share on other sites More sharing options...
gardan06 Posted October 2, 2006 Author Share Posted October 2, 2006 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.? Quote Link to comment https://forums.phpfreaks.com/topic/22247-cron-jobs/#findComment-102353 Share on other sites More sharing options...
gardan06 Posted October 2, 2006 Author Share Posted October 2, 2006 i do have shell access now, that's the one saying "SSH/Shell Access", right? what do i do next? Quote Link to comment https://forums.phpfreaks.com/topic/22247-cron-jobs/#findComment-102458 Share on other sites More sharing options...
obsidian Posted October 2, 2006 Share Posted October 2, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/22247-cron-jobs/#findComment-102462 Share on other sites More sharing options...
gardan06 Posted October 2, 2006 Author Share Posted October 2, 2006 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? Quote Link to comment https://forums.phpfreaks.com/topic/22247-cron-jobs/#findComment-102479 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.