bash - Need to add mysql query in cron job -


i need add mysql query in cron job. tried suggestions here not able do.

my query:

mysql -u root -pitvitv -e "use tvbsadmin; show full processlist;"> /mydirectory/processlist_auto.txt. 

tried write script below:

#!/usr/local/bin/bash /usr/local/bin/mysql -u root -pitvitv -e "use tvbsadmin; show full processlist;"> /seachange/processlist_auto.txt 

and added in cron job as:

05 * * * * root /mydirectory/processlist.sh 

please correct me if trying wrong. in advance

added mysql queries in script , included in crontab.

script:

#!/bin/bash echo $(date >> /seachange/unassigned_count.txt) mysql -d tvbsadmin -u root -pitvitv -e "select count(*) eam_package status in (1,3);" >> /seachange/unassigned_count.txt echo $(date >> /seachange/processlist_may07.txt) mysql -u root -pitvitv -e "select time,info information_schema.processlist info !='null';" >> /seachange/processlist_may07.txt 

cron entry:

*/10 * * * * cd /seachange && sh mysql_output.sh 

cron log o/p:

may 7 15:30:01 verzcore1 crond[20978]: (root) cmd (cd /seachange && sh mysql_output.sh)

it working fine!


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -