Re: Updating tables via cron

2002-01-04 Thread zb

Hi!

On Thu, 3 Jan 2002, Webmaster wrote:

>   I tried to search the archives for this but I can't find it.  (Not saying 
> it isn't there just I could not find it.)  I have a table that tracks 
> events on a monthly and daily basis.  Currently I am resetting the 
> appropriate fields to 0 on a daily and monthly basis (not fun).  Is there a 
> way to set a command in the cron table to do this for me 
> automatically?  Here are the details.
> 
> db name: activity
> daily field name: dr (needs to be reset to 0)
> monthly field name: mr (same as above)

test crontab entry:

* * * * * /usr/local/mysql/bin/mysql -e "use activity; update table_name
set dr=0"

Additionally the user of the cron should have a file ~/.my.cnf
to avoid giving the password in crontab:


[client]
password=your_password


>   I know how to tell cron the date/time I want an event to trigger, but I 
> don't know the syntax of the command to send.  Any help would be appreciated.

This one was easy :-)

> Thanks,
> David

HTH.

Regards, Zoltan


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: Updating tables via cron

2002-01-04 Thread DL Neil

David,
Was this question addressed?

> I tried to search the archives for this but I can't find it.  (Not saying
> it isn't there just I could not find it.)  I have a table that tracks
> events on a monthly and daily basis.  Currently I am resetting the
> appropriate fields to 0 on a daily and monthly basis (not fun).  Is there a
> way to set a command in the cron table to do this for me
> automatically?  Here are the details.
>
> db name: activity
> daily field name: dr (needs to be reset to 0)
> monthly field name: mr (same as above)
>
> I know how to tell cron the date/time I want an event to trigger, but I
> don't know the syntax of the command to send.  Any help would be appreciated.

Cron will allow you to put together shell scripts and work in other ways to achieve 
this. Will leave details to
you/your system/your preferences.

MySQL has a "batch mode". Once you know the terminology, a search of the manual will 
yield a ton of material.
Check out: 3.6  Using mysql in Batch Mode for
shell> mysql < batch-file
(you will probably need to study this to work out a more sophisticated command line 
than that)
For example:
shell> mysql database < script.sql > output.tab
which appears in section: 4.8.2  The Command-line Tool

The DuBois book discusses batch mode and gives a shell script example on p76.

Welling and Thomson discuss "file redirection" somewhat in passing on p195 and use it 
extensively, eg to set up
new db/tbl definitions (if they detail it elsewhere I've failed to note it).

Regards,
=dn



-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




RE: Updating tables via cron

2002-01-03 Thread Gary . Every

Try this:

echo "REPLACE INTO table_name (dr) VALUES ('0');" |
/usr/local/mysql/bin/mysql -u user -p password activity

or mysql -e "REPLACE INTO table_name (dr) VALUES ('0');" activity

-Original Message-
From: Webmaster [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 03, 2002 10:57 AM
To: [EMAIL PROTECTED]
Subject: Updating tables via cron


I tried to search the archives for this but I can't find it.  (Not
saying 
it isn't there just I could not find it.)  I have a table that tracks 
events on a monthly and daily basis.  Currently I am resetting the 
appropriate fields to 0 on a daily and monthly basis (not fun).  Is there a 
way to set a command in the cron table to do this for me 
automatically?  Here are the details.

db name: activity
daily field name: dr (needs to be reset to 0)
monthly field name: mr (same as above)


I know how to tell cron the date/time I want an event to trigger,
but I 
don't know the syntax of the command to send.  Any help would be
appreciated.


Thanks,
David



-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail
<[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




RE: Updating tables via cron

2002-01-03 Thread Land, Christopher

Here is a select statement, as example:

mysql -e "select * from user \G" mysql

Add user and password as required.

Xi2 ('sE-'tü)


-Original Message-
From: Webmaster [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 03, 2002 8:57 AM
To: [EMAIL PROTECTED]
Subject: Updating tables via cron


I tried to search the archives for this but I can't find it.  (Not
saying 
it isn't there just I could not find it.)  I have a table that tracks 
events on a monthly and daily basis.  Currently I am resetting the 
appropriate fields to 0 on a daily and monthly basis (not fun).  Is there a 
way to set a command in the cron table to do this for me 
automatically?  Here are the details.

db name: activity
daily field name: dr (needs to be reset to 0)
monthly field name: mr (same as above)


I know how to tell cron the date/time I want an event to trigger,
but I 
don't know the syntax of the command to send.  Any help would be
appreciated.


Thanks,
David



-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail
<[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Updating tables via cron

2002-01-03 Thread Webmaster

I tried to search the archives for this but I can't find it.  (Not saying 
it isn't there just I could not find it.)  I have a table that tracks 
events on a monthly and daily basis.  Currently I am resetting the 
appropriate fields to 0 on a daily and monthly basis (not fun).  Is there a 
way to set a command in the cron table to do this for me 
automatically?  Here are the details.

db name: activity
daily field name: dr (needs to be reset to 0)
monthly field name: mr (same as above)


I know how to tell cron the date/time I want an event to trigger, but I 
don't know the syntax of the command to send.  Any help would be appreciated.


Thanks,
David



-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php