The Little Guy Posted July 22, 2007 Share Posted July 22, 2007 Is it possible to have mysql run a sql script every 30 minutes? I wan't one to check if users ar still online... Link to comment https://forums.phpfreaks.com/topic/61182-solved-run-sql/ Share on other sites More sharing options...
AndyB Posted July 22, 2007 Share Posted July 22, 2007 php can. cron on unix, scheduler on windoze Link to comment https://forums.phpfreaks.com/topic/61182-solved-run-sql/#findComment-304459 Share on other sites More sharing options...
The Little Guy Posted July 22, 2007 Author Share Posted July 22, 2007 I am using a shared server, does it still work? Link to comment https://forums.phpfreaks.com/topic/61182-solved-run-sql/#findComment-304500 Share on other sites More sharing options...
AndyB Posted July 22, 2007 Share Posted July 22, 2007 I am using a shared server, does it still work? So am I and I have multiple cron tasks running. Your host may permit cron tasks. Check your server control panel and/or host FAQs Link to comment https://forums.phpfreaks.com/topic/61182-solved-run-sql/#findComment-304644 Share on other sites More sharing options...
The Little Guy Posted July 23, 2007 Author Share Posted July 23, 2007 OK... they do support, but How do I write a Cron Job? Link to comment https://forums.phpfreaks.com/topic/61182-solved-run-sql/#findComment-305165 Share on other sites More sharing options...
Wildbug Posted July 23, 2007 Share Posted July 23, 2007 What OS? Link to comment https://forums.phpfreaks.com/topic/61182-solved-run-sql/#findComment-305618 Share on other sites More sharing options...
The Little Guy Posted July 23, 2007 Author Share Posted July 23, 2007 Debian Linux Link to comment https://forums.phpfreaks.com/topic/61182-solved-run-sql/#findComment-305664 Share on other sites More sharing options...
Wildbug Posted July 23, 2007 Share Posted July 23, 2007 man crontab Link to comment https://forums.phpfreaks.com/topic/61182-solved-run-sql/#findComment-305682 Share on other sites More sharing options...
The Little Guy Posted July 23, 2007 Author Share Posted July 23, 2007 My host has a cron feature built into their panel (They made it themself). here is where I do the info: Command to run: (max 1000 characters) Use full paths to files and programs. Link to comment https://forums.phpfreaks.com/topic/61182-solved-run-sql/#findComment-305716 Share on other sites More sharing options...
The Little Guy Posted July 23, 2007 Author Share Posted July 23, 2007 I am assuming that I just need to place the file directory in that field like so: /var/log/date.log Link to comment https://forums.phpfreaks.com/topic/61182-solved-run-sql/#findComment-305729 Share on other sites More sharing options...
Wildbug Posted July 23, 2007 Share Posted July 23, 2007 Is that your MySQL script? You should probably run it with the MySQL client command. /usr/bin/mysql dbname --user=username --password=passwd < /var/log/date.log Link to comment https://forums.phpfreaks.com/topic/61182-solved-run-sql/#findComment-305737 Share on other sites More sharing options...
The Little Guy Posted July 23, 2007 Author Share Posted July 23, 2007 no... that was just an example, but here is what the page looks like where i enter in my information [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/61182-solved-run-sql/#findComment-305750 Share on other sites More sharing options...
Wildbug Posted July 24, 2007 Share Posted July 24, 2007 Okay, so you'll put the command in the "Command to run" box using full paths, like the example I put above. Link to comment https://forums.phpfreaks.com/topic/61182-solved-run-sql/#findComment-305878 Share on other sites More sharing options...
The Little Guy Posted July 24, 2007 Author Share Posted July 24, 2007 is it possible to run a .sql file with cron instead of a .php file? if so... how do I connect to the database with that file? Link to comment https://forums.phpfreaks.com/topic/61182-solved-run-sql/#findComment-305916 Share on other sites More sharing options...
Wildbug Posted July 24, 2007 Share Posted July 24, 2007 Yes, like in the example above, use the mysql client prog. http://dev.mysql.com/doc/refman/5.1/en/batch-commands.html Link to comment https://forums.phpfreaks.com/topic/61182-solved-run-sql/#findComment-306293 Share on other sites More sharing options...
The Little Guy Posted July 24, 2007 Author Share Posted July 24, 2007 OK... I created one... now I'll see if it works. I used this code: /home/ryannaddy/cron/logOut.sql Link to comment https://forums.phpfreaks.com/topic/61182-solved-run-sql/#findComment-306460 Share on other sites More sharing options...
Wildbug Posted July 24, 2007 Share Posted July 24, 2007 You need to write a whole command, just as you would from the command line, not just the name of the batch file. Link to comment https://forums.phpfreaks.com/topic/61182-solved-run-sql/#findComment-306499 Share on other sites More sharing options...
The Little Guy Posted July 24, 2007 Author Share Posted July 24, 2007 Before I try this... good or no? /usr/bin/mysql publicsize --user=cantremember --password=xxxxxx < /home/ryannaddy/cron/logOut.sql Link to comment https://forums.phpfreaks.com/topic/61182-solved-run-sql/#findComment-306521 Share on other sites More sharing options...
Wildbug Posted July 24, 2007 Share Posted July 24, 2007 Assuming that's the correct path to the mysql client, then YES! You should try it from the command line/shell prompt if you have access. If it works there, it should work in cron. Link to comment https://forums.phpfreaks.com/topic/61182-solved-run-sql/#findComment-306528 Share on other sites More sharing options...
The Little Guy Posted July 24, 2007 Author Share Posted July 24, 2007 if I run it in PuTTy, I get this: -bash: !!: event not found What does that mean? Link to comment https://forums.phpfreaks.com/topic/61182-solved-run-sql/#findComment-306542 Share on other sites More sharing options...
Wildbug Posted July 24, 2007 Share Posted July 24, 2007 No idea. Did you enter the command? The "!!" is used in bash to mean "the last command." i.e., if you ran, say, "ls -l" but forgot to add the path, you could type "!! /tmp" and get "ls -l /tmp"... but you didn't do that, did you? What's in your SQL script? Link to comment https://forums.phpfreaks.com/topic/61182-solved-run-sql/#findComment-306560 Share on other sites More sharing options...
The Little Guy Posted July 24, 2007 Author Share Posted July 24, 2007 Think it is because of my password? /usr/bin/mysql publicsize --user=limited --password=rmn!!2233 < /home/ryannaddy/cron/logOut.sql logOut.sql: UPDATE `users` SET `onlineStatus` = '0' WHERE `onlineStatus` = '1' AND (UNIX_TIMESTAMP(NOW())-`lastAccess` > 1800); Link to comment https://forums.phpfreaks.com/topic/61182-solved-run-sql/#findComment-306568 Share on other sites More sharing options...
Wildbug Posted July 24, 2007 Share Posted July 24, 2007 Oh. Yes, that's why. Quoting it should work: --password="rmn!!2233" Link to comment https://forums.phpfreaks.com/topic/61182-solved-run-sql/#findComment-306572 Share on other sites More sharing options...
The Little Guy Posted July 24, 2007 Author Share Posted July 24, 2007 OK... that removed the bash error, but now I get this: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) Link to comment https://forums.phpfreaks.com/topic/61182-solved-run-sql/#findComment-306576 Share on other sites More sharing options...
Wildbug Posted July 24, 2007 Share Posted July 24, 2007 Hmm, this would imply that the MySQL server is not running. Verify by running "ps aux|grep mysqld" from the shell prompt. Link to comment https://forums.phpfreaks.com/topic/61182-solved-run-sql/#findComment-306580 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.