marklarah Posted January 20, 2008 Share Posted January 20, 2008 Hi, you've all just seen my login script, but how do i set a cron in cPanel so that it checks every 10 minutes for an inactive user and resets their active bool? It updates the last active time each time a page loads with this: $id = $_SESSION['userID']; $lin = "UPDATE users SET llin = NOW() WHERE ID = '$id' "; mysql_query($lin) or die('Error, query failed now'); I have a bool field called active where 0 would be inactive. How would I do this? Quote Link to comment https://forums.phpfreaks.com/topic/86898-solved-how-to-do-a-cron/ Share on other sites More sharing options...
marklarah Posted January 20, 2008 Author Share Posted January 20, 2008 just do a normal php file? Quote Link to comment https://forums.phpfreaks.com/topic/86898-solved-how-to-do-a-cron/#findComment-444272 Share on other sites More sharing options...
marklarah Posted January 20, 2008 Author Share Posted January 20, 2008 <?php include 'dbs.php'; include 'bar.php'; $cnow = date("H:i:s") - date("H:10:s"); $lin = "UPDATE users SET active = '0' WHERE llin > NOW($cnow)"; mysql_query($lin) or die('Error, query failed now'); ?> Doesn't show any errors, but it doesn't work either. Quote Link to comment https://forums.phpfreaks.com/topic/86898-solved-how-to-do-a-cron/#findComment-444288 Share on other sites More sharing options...
marklarah Posted January 20, 2008 Author Share Posted January 20, 2008 ...help? Quote Link to comment https://forums.phpfreaks.com/topic/86898-solved-how-to-do-a-cron/#findComment-444396 Share on other sites More sharing options...
Fyorl Posted January 20, 2008 Share Posted January 20, 2008 Just put the path to the PHP script that you want to be run every 10 minutes into the cron manager in CPanel. Quote Link to comment https://forums.phpfreaks.com/topic/86898-solved-how-to-do-a-cron/#findComment-444444 Share on other sites More sharing options...
marklarah Posted January 20, 2008 Author Share Posted January 20, 2008 i have but it don't work Quote Link to comment https://forums.phpfreaks.com/topic/86898-solved-how-to-do-a-cron/#findComment-444628 Share on other sites More sharing options...
marklarah Posted January 20, 2008 Author Share Posted January 20, 2008 i get: /home2/tlscom/public_html/check.php: line 1: ?php: No such file or directory /home2/tlscom/public_html/check.php: line 2: include: command not found /home2/tlscom/public_html/check.php: line 3: include: command not found /home2/tlscom/public_html/check.php: line 4: syntax error near unexpected token `(' /home2/tlscom/public_html/check.php: line 4: `// $cnow = date("H:i:s") - date("H:10:s");' Thats from the output (from teh email) Quote Link to comment https://forums.phpfreaks.com/topic/86898-solved-how-to-do-a-cron/#findComment-444651 Share on other sites More sharing options...
marklarah Posted January 20, 2008 Author Share Posted January 20, 2008 it looks like it doesn't recognize the language as php. Is php okay? Also what should the normal permissions be for cron, so I can do i manually? at the mo it is 777, it was 644 before. Quote Link to comment https://forums.phpfreaks.com/topic/86898-solved-how-to-do-a-cron/#findComment-444661 Share on other sites More sharing options...
Fyorl Posted January 21, 2008 Share Posted January 21, 2008 Try putting '#!/usr/bin/php' right at the top of the file, before the '<?php' Quote Link to comment https://forums.phpfreaks.com/topic/86898-solved-how-to-do-a-cron/#findComment-445280 Share on other sites More sharing options...
marklarah Posted January 21, 2008 Author Share Posted January 21, 2008 Haaaa thankyou! Ill let you know in 10 mins if the script works. But what would be the best permissions for it? So i can run from the browser manually, and so the cron can do it too? Quote Link to comment https://forums.phpfreaks.com/topic/86898-solved-how-to-do-a-cron/#findComment-445355 Share on other sites More sharing options...
Fyorl Posted January 21, 2008 Share Posted January 21, 2008 Erm well you should only need read and execute permissions for the owner if your server's setup properly. If it's not then you might need to add execute permissions for group and/or others too. That's something only your hosts can dictate though. r-xr--r-- = 544 r-xr-xr-x = 555 rwxr--r-- = 744 (probably what it should be ideally as presumably you still want to be able to write to it) Quote Link to comment https://forums.phpfreaks.com/topic/86898-solved-how-to-do-a-cron/#findComment-445423 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.