modernmafia Posted November 9, 2011 Share Posted November 9, 2011 i recently bought a site and it has cron jobs but when on my control panel it asks me to put ina command for the cron and i have no idea what to do Quote Link to comment Share on other sites More sharing options...
sniko Posted November 14, 2011 Share Posted November 14, 2011 I'm familiar with cron jobs at a McCodes level. Basically, you need to create a file, which includes queries/content that you want to be executed every x minutes/hours/days/weeks. So, say you want something to be executed every day. First we would create a file, something like; crons/1day_something.php And this is what the content of that file will look like; <?php /* * Establish database connection for database queries * Cron example, 1 day. */ $code = "XXX"; /* Change this code, so only you know it, so a 3rd party cannot manually execute the cron */ if(!$_GET['code'] OR $_GET['code'] != $code) { exit; /* The script will not continue */ } $message = "This\nEmail\nWill\nSend\nEvery\nDay"; $message = wordwrap($message, 70); $get = mysql_query("SELECT `email` FROM `user_accounts` WHERE `email`!="""); while($r = mysql_fetch_array($get)) { mail("{$r['email']}", "5 Day email", $message); } ?> Now we have the file, let's set up the cron. Now, this will execute the file crons/1day_something.php every day, automatically. ~sniko Quote Link to comment Share on other sites More sharing options...
Uridium Posted November 14, 2011 Share Posted November 14, 2011 Just to note you dont always need to use a code at the end of a Cron url and even if users manage to find the cron file to run, It still wouldnt work for them as its being called for by a file with a function to actually run the cron Quote Link to comment Share on other sites More sharing options...
sniko Posted November 14, 2011 Share Posted November 14, 2011 Just to note you dont always need to use a code at the end of a Cron url and even if users manage to find the cron file to run, It still wouldnt work for them as its being called for by a file with a function to actually run the cron As i said earlier (..and this isn't shouting at you :P) my cron experience comes from McCodes, and if you, for example, go to http://www.a-random-game.com/cron_hour.php?code=code as a user, it still would run. From my experience anyway. Maybe I interpreted your reply wrong, but you were saying that we don't need a ?code as it wouldn't run anyway? I think it would. Or are you saying, something else? Quote Link to comment Share on other sites More sharing options...
Uridium Posted November 14, 2011 Share Posted November 14, 2011 Nah didnt think you was shouting at me Sniko and I hope my post didnt come across the same.. Quote Link to comment 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.