Cron Job And Time Select Question
I am trying to figure out a select...where statement to use in a script running via cron job several times an hour.
example in plain english:cron job runs hourly, e.g. 12:50, 1:10, 1:30
need to select records where a datetime field is > 12:45
next hour I need to select where the datetime field is > 1:45
and so on....How do I calculate the time to use in my where statement?
View Complete Forum Thread with Replies
Related Forum Messages:
Running SELECT INTO OUTFILE As A CRON Job
I need to run the "SELECT * INTO OUTFILE" command as a CRON job. I can do this via command line and it works fine, but when I add it to my CRON file it does not run. My problem is I dont know how to create a CRON job or script that logs into mySQL and then runs the "SELECT * INTO OUTFILE" command. I am currently running "mySQL DUMP" as a CRON job without any problem.
View Replies !
Cron Job
I've tried reading tutorials, posts, anything.....in order to figure out the correct steps to take in order to have a cron job. I've installed a script on my server that is a calendar and already has the php file needed in order to send automatic emails to me....but I'm totally lost as to what I need to do. At the prompt where I would usually log in and connect to mysql database, I'm totally lost....do I log in or do I just run it from the command line? then what? I have the php file (assuming of course that other than the username, password etc is correct) so I think all I need to do is set it up.
View Replies !
Add Time Using A Select Query
Hello, how can I add, say, 2 hrs from a time in a database using a select query. I have searched the forums but cannot find an answer. Is it possible PHP Code: select date, `time` as timetime , time_format(`time','%l:%i %p') as Printtime, client, address from..........
View Replies !
Select Between Date And Time
I have field date and time respectively. I want to select date between (date1 and time1 > 17) and (date2 < 17) I tried two ways but doesn't work, please see code below. SELECT * from purchases_suppliers WHERE (date_invoice >= '2009/02/25' and time_invoice > 17) AND (date_invoice <= '2009/02/27' AND time_invoice < 17) SELECT * from purchases_suppliers WHERE date_invoice between ('2009/02/25' ANd time_invoice > 17) AND ('2009/02/27' AND time_invoice < 17 )
View Replies !
Update And Select Same Time
Code: UPDATE art SET art.art_writer = (SELECT writer.writer_name, art.art_author FROM writer, author WHERE art.art_author LIKE 'writer.writer_name') Is this query syantex is ok ? Where, art_writer is empty fild where I want to put correct value which is in writer table and it should similar to value in art_author filed.
View Replies !
Mysql And Cron
I have a script that is used for updating an image directory based on contents in a database. The script does the following: runs several queries against different tables in a database; returns several lists of pictures being used in the database; removes any obsolete images from specific directories. The script is bash shell script. The problem is that I can run this script from the command line without any problems. After testing this script several times, I decided to put into crontab so that it can execute daily. From crontab, it will not execute the mysql commands in the file saying that "no commands were found". Error Log: scriptname.sh: line #: mysql: command not found My sql command in my script is as follows: mysql --user=$USERNAME --password=$PASSWORD --host=$DBHOST dbname <<COMMANDS SELECT PHOTO INTO OUTFILE "filename" FROM table_name WHERE PHOTO != "" AND PHOTONAME LIKE "\%0"; COMMANDS Also, please note that I tried this command without 'PHOTONAME LIKE "\%0"' to see if the % was causing any problems, and even with that removed, it would not execute the mysql statements in this script.
View Replies !
Cron Facility
Anybody could tell me how a mysql script could be run on mysql on some interval like cron facility in Linux system?. I am using Windows 2K machine.Actually I am developing a PHP application by which if any user logged in but idle for 10 minutes then the user will be forced logged out. To implement it I am saving timestamp of the user's login time on mysql database. The daemon/service script will identify this type logged user's and delete its timestamp records from database. How this could be done?
View Replies !
DB Backup With Cron
I’d like to backup some MYSQL databases with cron. I don’t need anything fancy, I’d like to tar up a few tables. I see a lot of utilities to do this, but that seems a but much for what I need.
View Replies !
OUT FILE Cron Job
I am running a cron job that calls a script to export data from a single table on a The query in my script looks like this: Code: SELECT * INTO OUTFILE "/var/www/path/to/webroot/htdocs/data/data.csv" FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY " " FROM tableName; Is there anything that can be added to that query to allow "data.csv" to be overwritten every time it runs? Right now, I get an error saying it can't be overwritten. If this cannot be done, I can run another script to delete the file before the next time the 1st script runs, but I was hoping to have it all taken care of in the SQL query.
View Replies !
Use Of Mysql Via Cron
I have a shell script that invokes mysql (and works) using -u, -p and -h to specify user pwd and host. When I try to run this same script via cron, I get error 1251. I tried exporting LOGNAME, USER, and HOST in the script but it did not help. Can anyone suggest what might be causing this to not run when invoked via cron?
View Replies !
Using Cron To Run A Mysql Job
I intend scheduling an event such as Changing the status of records at a certain time. Ie. -> On every monday -> update mytable set status = archive where status = filed How can I archive this using cron?
View Replies !
Firing Off SQL Via Cron
Can anyone point me to the basics of how firing off a sql statement can be done automatically by CRON on a unix box? Essentially I want to have a sql sript that clears daily totals in a table every night at 00:01 am -- I understand the script part... but I don't know HOW that happens with Cron
View Replies !
Select Statement Where Time <= 5min Ago
i tried many different MySQL fucntions and looked through the MySQL manual, and it didnt help me any. What i want to do is select all rows from a table where my time column(DATETIME) is less then or equal to 5 minutes ago from now().
View Replies !
Select Date And Time In Same Column
I have table called mytable and there I have column named time example: time 2006-07-10 10:28:06 2006-08-18 20:48:22 2006-09-15 12:11:41 2006-10-12 23:06:02 is there any possibles that I can make query example: SELECT *FROM mytable WHERE date BETWEEN 2006-07-10 AND 2006-09-15 AND time BETWEEN 10:28:06 AND 12:11:41 My point is can I make query where I first find between date and after that I make query where I find between time when information is in the same column?
View Replies !
Select Date Ignoring Time
Im using a datetime fields eg. "2006-08-07 16:01:09" and I want to select dates... eg. "select * from mytable where mydate="2006-08-07" ignoring the time.
View Replies !
Rmysql - Cron Facility
Anybody could tell me how a mysql script could be run on mysql on some interval like cron facility in Linux system?. I am using Windows 2K machine. Actually I am developing a PHP application by which if any user logged in but idle for 10 minutes then the user will be forced logged out. To implement it I am saving timestamp of the user's login time on mysql database. The daemon/service script will identify this type logged user's and delete its timestamp records from database. How this could be done?
View Replies !
Can Bash Replace Cron?
I want to use a bash script to check that any of my PSV files contain data before dropping and creating tables in a DBs. For years I have used a cron to just run the ".sql" command files - eg: >>* * * * /usr/home/master/usr/local/bin/mysql -u uname -p pword < /usr/home/master/command/somefile.sql 1> /dev/null<< The somefile.sql file is basic like this: Code:
View Replies !
Cron Line In FeeBSD
Ok, where is the location and the file name, in which I type in the start command line to start my database in FreeSBD 4.4 ?? I bought a book the keeps reffering to the rc.local, but that looks like a basic network config file.
View Replies !
MySQLDump Cron Script
I am currently using MySQLDumper to dump my databases manually. I would like to setup a weekly automatic backup that MySQLDumper can use. Can anyone point me in the right direction for a cron script. I am completely new to .pl and am not sure where to start.
View Replies !
Easy SELECT With OR Takes A Very Long Time
We've got a database with about 1000000 books. A query in the table BOOKS for the TITLE 'java' is very fast. We have a fulltext index on the column TITLE. However, if we want to do a exact same query and include the rule that the book with ISBN '0131016210' always should be included - then the query take several seconds to finish: SELECT * FROM C_BOOK WHERE MATCH(NAME) AGAINST ('java') AND (ISBN LIKE '0%' OR ISBN LIKE '1%') OR ISBN = '0131016210' ISBN is the PRIMARY KEY. Is there anything I can do about this?
View Replies !
Datatype TIME - Select Statement Format
The table I have has two columns of ID and INTERVALS. The INTERVALS is datatype TIME. Whenever I do a select I always get the table back showing the time in the format HH:MM:SS like for 11am I get back 11:00:00. I only want HH:MM like 11:00. How do I achieve this? I have tried to limit to 2 decimal places but that has not worked so far. ...
View Replies !
Select Rows From Date Not Time In Where Clause
I am trying to select all the rows that where entered today and I have a datetime type column to store the date data in. How can I specify in my where clause to select where datecol=today and not have to specify the time? If I do where datecol=<?php date('Y-m-d'); ?> its not working
View Replies !
Cron Job Backup Of MySQL Database
I would like to backup a mysql database to a text file using a cron job and then have the file mailed to an email address. Can anyone point me in the right direction on doing this type of thing? I dont have much expericnce with CRON.
View Replies !
Syncronize 2 Tables From 2 Different Databases Using A Cron Job
I want to set up a cronjob to syncronize 2 tables (only) from one database to another. The databases have the same content and reside on the same MySQL server. I want this because I have 2 websites using the same dontent from this table and I don't want them to use the same database, I prefer them to use different databases. The server is Ubuntu 8.04, if it matters, it has apache2 and php5. MySQL is also 5. I'd apreciate any help you can give me, I didn't get much from the Ubuntu forum, regarding this thing, and I hope I'll find more support here. BTW, since I'm really a noob, please post an example easy to understand rather then the explanation of the entire process :). Let's just call, for this example, the datababes DB1 and DB2 and the tables TB1 and TB2
View Replies !
Backup Db Trough Cron An Mysqldump ?
I'm running two ubuntu servers, one is operational and the other is a backupserver. Im looking for a good way to do a regurlay dump, at night and perhaps at noon. Can i do a mysqldump while people are using the server, do i ris loss of data. Is it better to stop mysql to perform a dump. Or is there an other standard way to keep my backupserver synchronised withe reasonable delay ?
View Replies !
PHP/MySQL Sorting By Date & Time (using Non Military Time)
This is probably a simple issue but I have searched online and can't find an answer. I am using PHP/MySQL and I guess the most intuitive would be to have three select boxes containing HOUR / MINUTE / AM,PM option. Then store the time into mysql using there functions so I can output the data sorting them all by date and time. All the examples I have seen are for military time only but I'm sure there has got to be a simple mysql function or php function that converts non military to military and a formatting function to display with the AM / PM. But I have not found it.
View Replies !
Compare Time Posted With Current Time Not Working
May I know how to get records with interval of 1 hour in database where the posting time is in this format '2008-05-15 00:10:40' I tried with this : $query="SELECT date,name FROM message WHERE (timediff(date,NOW())<=CRUDATE() CURTIME())"; But is not working. May I know what is the correct way of doing it?
View Replies !
Minutes + TIME = TIME Function
I need some way to convert minutes (e.g. 80 mins) to SQL TIME (e.g. 01:20:00) in order to add it to another TIME var. Is there any way to do this? I really dont want to convert my whole db. Basically, I want to do: e.g. 80 + 10:00:00 = 11:20:00.
View Replies !
How To Retrieve Mean Time Between Time Stamps
I have a table that stores failure information of external application. The time stamp of every failure event is stored. Now I'd like to make some system performance & reliability statistics calculations based on time stamps in certain recordset; mean time between failure MTBF, down time DT, etc. Example: 2007-09-27 12:23:52 2007-09-27 08:50:23 2007-09-26 23:31:34 2007-09-26 21:45:33 Here the times between are (hours:mins): 3:33, 9:18, 1:46 and MTBF=4:52 Any effective possibility to make this example within a single query - or a procedure is needed?
View Replies !
Time Format Military Time
I know the time format it HH:MM:SS in mysql but can I input military time? reason I can is that I want to later extract that information for calculations and military time is easier to work with.
View Replies !
Date-time Overlaps Another Time
had a time question in mysql... i have a start and end time for a meeting table and i am comparing whether a new meeting conflicts with another meeting in same room on the same date. i was wondering if i could check whether the 'date-time duration' in anyway overlaps another meetings date-time duration. visualized below... ............|____compareToThisMeeting__| .....|_________meetingNewOverlaps__________| i was doing something dumb before i realized i needed soemthing more complex (checking whether the start time of new meeting was 'BETWEEN' the start and end times of a meeting and whether the end time time is as well but i forgot the duration/middle value hehe). (using asp) and just returning booleans with a mySQL SELECT statement is what i am looking for like... //within a loop in asp for meetings on same date/room "SELECT '"+ year+"-"+month +"-"+day +" " + startHourString +":" + startMinuteString +":00''"+ " BETWEEN '"+ thisMeetingStart +"' AND '"+ thisMeetingEnd +"'"; (this doesnt cover the 'middle' overlap areas though)
View Replies !
Date Field, Time Field, Sort By Date And Time
I have a MySQL date field (e.g 13/12/2006) and a MySQL time field (e.g.13:00) in the same row. I'd like to join these two fields to make a date/time field (e.g. 13:00 13/12/2006) on the fly and to be able to sort the query results on the resulting field.
View Replies !
INSERT INTO SELECT Taking Forever But SELECT Part Is Fast?
I have the following mysql code to insert about a million rows. This takes quite a long time (over 50 min). However, when I just run the query alone without the INSERT command, the query itself only takes under 5 minutes. Is there a way I could speed up the inserting?? insert into tblc select tbla.* from tblb inner join tbla on tbla.issuer_id = tblb.issuer_id;
View Replies !
SELECT INNER JOIN Performance VS Single Table SELECT
I have designed my database using a somewhat oriented approach. Rows are objects, and different type of objects are in different tables, but since my objects share a common set of fields like ExpireDate, Archived, Draft, CreateDate, CreatorID, etc; I have an 'objects' table with these columns, and I have set up a foreign key in other tables where there is a need for a row-to-row integrity. Now my question is, since I have to SELECT using INNER JOIN with object and the corresponding table, merely to filter out archived rows, I am wondering if I would be better off actually putting the common fields into each respective table and get rid of the 'objects' table altogether. I mean, is it more job for the server to actually JOIN the tables for each SELECT versus having a clean design with object oriented approach ? How bad is my design, and what are the recommendations of experts who obviously were tempted to create an object oriented database design?
View Replies !
4.1.1 And 5.0.0 At The Same Time ?
mysql-4.1.1-alpha-win.zip mysql-5.0.0-alpha-win.zip Is it possible to install and run both MySQL versions under windows 2000? On one computer. I don't intend to run them at the same time, but investigate the new features. I'd like to install them in different directories and select the one that suits my needs.
View Replies !
SUM Time
I have managed to write the following query, which works well with the sum for the TOTAL values, but the values I get for Queue1, Queue2, Queue3, Queue4 all give me the wrong totals. Where am I actually going wrong? The values within the table has been set as TIME with a default of 00:00:00. the following is my query....
View Replies !
|