Here is MySQL on CentOS.
I would like to execute Update SQL at 24:05 every day.
Therefore, I created a sh file.
The inside is written like this.
mysql -h localhost -u user -ppassword lang -e "SET SQL_SAFE_UPDATES = 0;UPDATE table SET member_type = 1 WHERE id = 20;"
If i enter the following on the terminal, it will be updated properly.
Command line #'/home/user/document/mysql_everyday.sh'
But when I run it as cron, Update doesn't work well.
Contents of cron.conf file
5 0 * * *'/home/user/document/mysql_everyday.sh'
(Other sh files that are run regularly are also listed here, and they work normally.)
If i enter a shell file name in the terminal and press Enter, it works.
Is not all sh files work with cron?
One thing I'm worried about is when I enter the shell file name in the terminal, the following warning appears.
mysql: [Warning] Using a password on the command line interface can be insecure.
/home/user/document/mysql_everyday.sh: line 4:/root: directory
If anyone is familiar, please give me an answer.
Answer # 1
Is not all sh files work with cron?
Any command that doesn't need to interact with humans can be run with cron.
If you have configured to send mail from that OS, cron errors will be notified by email from root to the running user.
If you find it difficult to set up email,
5 0 * * * /home/user/document/mysql_everyday.sh 2>/tmp/errormsg
Confirm the error message with.
The difference between running from the command line and running from cron is
・ Current directory
・ Environment variables
Standard input/output, error output
is. In many cases, environment variables, especially
PATH, affect execution differences.
Answer # 2
When running as cron,environment variablessuch as
$PATHare different from the login shell.
First of all, let's verify that what is the problem by running it with cron so that the log is properly output.
Answer # 3
I was misunderstood.
Thank you for telling me how to output and analyze logs.
Forgetting to use the Crontab command led to the solution of this issue.
I'm sorry for all the noise.
- i want to run any php file with gulp4
- mysql - in sql case when, i want to name more than one same as ~
- i want to import the file into mysql
- i want to run a bat file on the aspnet site
- i want to import a csv file into mysql
- mysql - i want to do a full text search
- mysql - i want to know how to use sql bit
- python - i want to execute an exe file by double-clicking
- php - i want to upload a file to wordpress
- i want to read a csv file in c # and output it in json format
- mysql - i want to link primary key and foreign key
- linux - i want to convert a json file to a csv file
- mysql - sql update statement
- python - i want to convert h5 file to mlmodel
- file - i want to cancel git add
- python - i want to convert a text file into a voice file
- java - i want to find a file and overwrite it
- i want to download a csv file as a template with php
- postgresql - [sql] i want to join two tables
- i'm stumbling upon inserting data into mysql using a shell script file
- rails6 mysql80 dcoker environment rails db:create fails
- i want to stop the mysql server
- ruby - the jorurimail database cannot be created and cannot be used
- is there a problem with the connection between mysql 80 and odbc 526 (win10)?
- unable to connect to phpmyadmin with php source code on centos 7 vps
- centos7 mysql 57 install gives no more mirrors to try error
- cannot install mysql56 on centos6 with dot install command /runsh
- after changing the mysql authentication plugin, i can no longer log in
- about the error that occurred during the test of mysql full dump to reduce the bloated ibdata1 file of mysql on sakura rental se