I have a sh script. How to run it using crontab?
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
I have the following file execute-backup-from-container.sh
. The content of this file is:
#!/bin/bash
FILE=minime.sql.`date +"%Y%m%d".gz`
CONTAINER='mysql_01'
SCRIPT_ON_CONTAINER='/container-mysql-dump.sh'
$OUTPUT=$(docker exec $CONTAINER /$SCRIPT_ON_CONTAINER)
echo "=============="
echo "$CONTAINER:/$FILE"
echo "=============="
docker cp "$CONTAINER:/$FILE" backup-data/
When I run crontab -e
I am putting the following:0 5 * * 1 /home/me/projects/execute-backup-from-container.sh
This means that the execute-backup-from-container.sh
should be executed every day at 5:00 am.
The problem is that the script is not executed at all.
So what on earth is the problem? Why is it not executed?
linux bash shell-script shell cron
add a comment |Â
up vote
1
down vote
favorite
I have the following file execute-backup-from-container.sh
. The content of this file is:
#!/bin/bash
FILE=minime.sql.`date +"%Y%m%d".gz`
CONTAINER='mysql_01'
SCRIPT_ON_CONTAINER='/container-mysql-dump.sh'
$OUTPUT=$(docker exec $CONTAINER /$SCRIPT_ON_CONTAINER)
echo "=============="
echo "$CONTAINER:/$FILE"
echo "=============="
docker cp "$CONTAINER:/$FILE" backup-data/
When I run crontab -e
I am putting the following:0 5 * * 1 /home/me/projects/execute-backup-from-container.sh
This means that the execute-backup-from-container.sh
should be executed every day at 5:00 am.
The problem is that the script is not executed at all.
So what on earth is the problem? Why is it not executed?
linux bash shell-script shell cron
@steeldriver you are right. If I want to make it every day should I have to put*
instead of1
?
â Cristian
Mar 23 at 23:52
If any of the answers solved your problem, please accept it by clicking the checkmark next to it. Thank you!
â Jeff Schaller
Mar 25 at 19:01
1
Also, you have a syntax error in the script:$OUTPUT=...
should just beOUTPUT=...
â Jeff Schaller
Mar 27 at 12:38
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I have the following file execute-backup-from-container.sh
. The content of this file is:
#!/bin/bash
FILE=minime.sql.`date +"%Y%m%d".gz`
CONTAINER='mysql_01'
SCRIPT_ON_CONTAINER='/container-mysql-dump.sh'
$OUTPUT=$(docker exec $CONTAINER /$SCRIPT_ON_CONTAINER)
echo "=============="
echo "$CONTAINER:/$FILE"
echo "=============="
docker cp "$CONTAINER:/$FILE" backup-data/
When I run crontab -e
I am putting the following:0 5 * * 1 /home/me/projects/execute-backup-from-container.sh
This means that the execute-backup-from-container.sh
should be executed every day at 5:00 am.
The problem is that the script is not executed at all.
So what on earth is the problem? Why is it not executed?
linux bash shell-script shell cron
I have the following file execute-backup-from-container.sh
. The content of this file is:
#!/bin/bash
FILE=minime.sql.`date +"%Y%m%d".gz`
CONTAINER='mysql_01'
SCRIPT_ON_CONTAINER='/container-mysql-dump.sh'
$OUTPUT=$(docker exec $CONTAINER /$SCRIPT_ON_CONTAINER)
echo "=============="
echo "$CONTAINER:/$FILE"
echo "=============="
docker cp "$CONTAINER:/$FILE" backup-data/
When I run crontab -e
I am putting the following:0 5 * * 1 /home/me/projects/execute-backup-from-container.sh
This means that the execute-backup-from-container.sh
should be executed every day at 5:00 am.
The problem is that the script is not executed at all.
So what on earth is the problem? Why is it not executed?
linux bash shell-script shell cron
asked Mar 23 at 23:46
Cristian
265212
265212
@steeldriver you are right. If I want to make it every day should I have to put*
instead of1
?
â Cristian
Mar 23 at 23:52
If any of the answers solved your problem, please accept it by clicking the checkmark next to it. Thank you!
â Jeff Schaller
Mar 25 at 19:01
1
Also, you have a syntax error in the script:$OUTPUT=...
should just beOUTPUT=...
â Jeff Schaller
Mar 27 at 12:38
add a comment |Â
@steeldriver you are right. If I want to make it every day should I have to put*
instead of1
?
â Cristian
Mar 23 at 23:52
If any of the answers solved your problem, please accept it by clicking the checkmark next to it. Thank you!
â Jeff Schaller
Mar 25 at 19:01
1
Also, you have a syntax error in the script:$OUTPUT=...
should just beOUTPUT=...
â Jeff Schaller
Mar 27 at 12:38
@steeldriver you are right. If I want to make it every day should I have to put
*
instead of 1
?â Cristian
Mar 23 at 23:52
@steeldriver you are right. If I want to make it every day should I have to put
*
instead of 1
?â Cristian
Mar 23 at 23:52
If any of the answers solved your problem, please accept it by clicking the checkmark next to it. Thank you!
â Jeff Schaller
Mar 25 at 19:01
If any of the answers solved your problem, please accept it by clicking the checkmark next to it. Thank you!
â Jeff Schaller
Mar 25 at 19:01
1
1
Also, you have a syntax error in the script:
$OUTPUT=...
should just be OUTPUT=...
â Jeff Schaller
Mar 27 at 12:38
Also, you have a syntax error in the script:
$OUTPUT=...
should just be OUTPUT=...
â Jeff Schaller
Mar 27 at 12:38
add a comment |Â
3 Answers
3
active
oldest
votes
up vote
4
down vote
The cron fields corresponding to your entry mean:
minute: 0
hour: 5
day of month: *
month: *
day of week: 1
command: /home/me/projects/execute-backup-from-container.sh
which translate in English to: Mondays at 5am (any day of the month, any month).
If you want it to be executed:
every day at 5:00 am
then you want that 5th field to be a *
:
0 5 * * * /home/me/projects/execute-backup-from-container.sh
good point there. I modified the1
into*
to be executed every day of the week, but still does not execute the script.
â Cristian
Mar 27 at 12:36
is there a cron error message in the logs? Is the script executable?
â Jeff Schaller
Mar 27 at 12:37
No, there are no error messages in the logs. I have read the logs with ` grep CRON /var/log/syslog`
â Cristian
Mar 27 at 16:34
add a comment |Â
up vote
1
down vote
Did you check that the file is set to be executable? Here is an example of marking a script as executable:
$ ls -l test.sh
-rw-r--r-- 1 ahill ahill 0 Mar 23 19:30 test.sh
$ chmod +x test.sh
$ ls -l test.sh
-rwxr-xr-x 1 ahill ahill 0 Mar 23 19:30 test.sh
The next thing to check is the environment. cron jobs inherit no environment by default. The "fix" is discussed here:
How can I run a cron command with existing environmental variables?
One of the reasons that the environment is a big deal is that cron might not even find bash! see: https://www.digitalocean.com/community/questions/why-is-cron-not-running-my-sh-script
If you still cannot figure it out, I would do a test: Change your cron job from:
0 5 * * * /home/me/projects/execute-backup-from-container.sh
to:
0 5 * * * /home/me/projects/execute-backup-from-container.sh >> ~/script_errors.log 2>&1
What will happen: the next time cron launches the job, error messages produced will be dumped into the text file script_errors.log. (change the path to the script_errors.log file to whatever seems appropriate, but make sure the path exists, though the file does not need to.)
I also noticed something in the OP that might be the real problem: the word "container." If the script is inside of a Docker container, then this is likely the solution:
https://www.ekito.fr/people/run-a-cron-job-with-docker/
This answer misses the point that the schedule used in the crontab is wrong.
â Kusalananda
Mar 24 at 15:29
You right... should have looked at that first... but I will leave it here as it might help someone else that is searching.
â Art Hill
Mar 26 at 15:06
Good point with the permissions. I had already put 777 toexecute-backup-from-container.sh
file before posting the question, so it does not help that, but I will check theenvironment variable
solution and let you know.
â Cristian
Mar 27 at 12:38
So I have used the following environment variables but still not working:HOME=/home/cristian LOGNAME=cristian PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin SHELL=/bin/bash PWD=/home/cristian BASH_ENV=/home/cristian/.profile
â Cristian
Mar 27 at 17:08
1
I would do a test: Change your cron job from: 0 5 * * * /home/me/projects/execute-backup-from-container.sh to: 0 5 * * * /home/me/projects/execute-backup-from-container.sh >> ~/script_errors.log 2>&1 What will happen: the next time cron launches the job, error messages produced will be dumped into the text file script_errors.log. (change the path to the script_errors.log file to whatever seems appropriate, but make sure the path exists, but he file does not need to.)
â Art Hill
Mar 28 at 22:34
 |Â
show 1 more comment
up vote
0
down vote
After keeping into account all the answers, the last issue was in the last line:
docker cp "$CONTAINER:/$FILE" backup-data/
The last line should have been
docker cp "$CONTAINER:/$FILE" docker-projects/mysql/backup-data/
Thank you all for your support.
add a comment |Â
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
4
down vote
The cron fields corresponding to your entry mean:
minute: 0
hour: 5
day of month: *
month: *
day of week: 1
command: /home/me/projects/execute-backup-from-container.sh
which translate in English to: Mondays at 5am (any day of the month, any month).
If you want it to be executed:
every day at 5:00 am
then you want that 5th field to be a *
:
0 5 * * * /home/me/projects/execute-backup-from-container.sh
good point there. I modified the1
into*
to be executed every day of the week, but still does not execute the script.
â Cristian
Mar 27 at 12:36
is there a cron error message in the logs? Is the script executable?
â Jeff Schaller
Mar 27 at 12:37
No, there are no error messages in the logs. I have read the logs with ` grep CRON /var/log/syslog`
â Cristian
Mar 27 at 16:34
add a comment |Â
up vote
4
down vote
The cron fields corresponding to your entry mean:
minute: 0
hour: 5
day of month: *
month: *
day of week: 1
command: /home/me/projects/execute-backup-from-container.sh
which translate in English to: Mondays at 5am (any day of the month, any month).
If you want it to be executed:
every day at 5:00 am
then you want that 5th field to be a *
:
0 5 * * * /home/me/projects/execute-backup-from-container.sh
good point there. I modified the1
into*
to be executed every day of the week, but still does not execute the script.
â Cristian
Mar 27 at 12:36
is there a cron error message in the logs? Is the script executable?
â Jeff Schaller
Mar 27 at 12:37
No, there are no error messages in the logs. I have read the logs with ` grep CRON /var/log/syslog`
â Cristian
Mar 27 at 16:34
add a comment |Â
up vote
4
down vote
up vote
4
down vote
The cron fields corresponding to your entry mean:
minute: 0
hour: 5
day of month: *
month: *
day of week: 1
command: /home/me/projects/execute-backup-from-container.sh
which translate in English to: Mondays at 5am (any day of the month, any month).
If you want it to be executed:
every day at 5:00 am
then you want that 5th field to be a *
:
0 5 * * * /home/me/projects/execute-backup-from-container.sh
The cron fields corresponding to your entry mean:
minute: 0
hour: 5
day of month: *
month: *
day of week: 1
command: /home/me/projects/execute-backup-from-container.sh
which translate in English to: Mondays at 5am (any day of the month, any month).
If you want it to be executed:
every day at 5:00 am
then you want that 5th field to be a *
:
0 5 * * * /home/me/projects/execute-backup-from-container.sh
edited Mar 24 at 13:55
answered Mar 24 at 0:49
Jeff Schaller
31.2k846105
31.2k846105
good point there. I modified the1
into*
to be executed every day of the week, but still does not execute the script.
â Cristian
Mar 27 at 12:36
is there a cron error message in the logs? Is the script executable?
â Jeff Schaller
Mar 27 at 12:37
No, there are no error messages in the logs. I have read the logs with ` grep CRON /var/log/syslog`
â Cristian
Mar 27 at 16:34
add a comment |Â
good point there. I modified the1
into*
to be executed every day of the week, but still does not execute the script.
â Cristian
Mar 27 at 12:36
is there a cron error message in the logs? Is the script executable?
â Jeff Schaller
Mar 27 at 12:37
No, there are no error messages in the logs. I have read the logs with ` grep CRON /var/log/syslog`
â Cristian
Mar 27 at 16:34
good point there. I modified the
1
into *
to be executed every day of the week, but still does not execute the script.â Cristian
Mar 27 at 12:36
good point there. I modified the
1
into *
to be executed every day of the week, but still does not execute the script.â Cristian
Mar 27 at 12:36
is there a cron error message in the logs? Is the script executable?
â Jeff Schaller
Mar 27 at 12:37
is there a cron error message in the logs? Is the script executable?
â Jeff Schaller
Mar 27 at 12:37
No, there are no error messages in the logs. I have read the logs with ` grep CRON /var/log/syslog`
â Cristian
Mar 27 at 16:34
No, there are no error messages in the logs. I have read the logs with ` grep CRON /var/log/syslog`
â Cristian
Mar 27 at 16:34
add a comment |Â
up vote
1
down vote
Did you check that the file is set to be executable? Here is an example of marking a script as executable:
$ ls -l test.sh
-rw-r--r-- 1 ahill ahill 0 Mar 23 19:30 test.sh
$ chmod +x test.sh
$ ls -l test.sh
-rwxr-xr-x 1 ahill ahill 0 Mar 23 19:30 test.sh
The next thing to check is the environment. cron jobs inherit no environment by default. The "fix" is discussed here:
How can I run a cron command with existing environmental variables?
One of the reasons that the environment is a big deal is that cron might not even find bash! see: https://www.digitalocean.com/community/questions/why-is-cron-not-running-my-sh-script
If you still cannot figure it out, I would do a test: Change your cron job from:
0 5 * * * /home/me/projects/execute-backup-from-container.sh
to:
0 5 * * * /home/me/projects/execute-backup-from-container.sh >> ~/script_errors.log 2>&1
What will happen: the next time cron launches the job, error messages produced will be dumped into the text file script_errors.log. (change the path to the script_errors.log file to whatever seems appropriate, but make sure the path exists, though the file does not need to.)
I also noticed something in the OP that might be the real problem: the word "container." If the script is inside of a Docker container, then this is likely the solution:
https://www.ekito.fr/people/run-a-cron-job-with-docker/
This answer misses the point that the schedule used in the crontab is wrong.
â Kusalananda
Mar 24 at 15:29
You right... should have looked at that first... but I will leave it here as it might help someone else that is searching.
â Art Hill
Mar 26 at 15:06
Good point with the permissions. I had already put 777 toexecute-backup-from-container.sh
file before posting the question, so it does not help that, but I will check theenvironment variable
solution and let you know.
â Cristian
Mar 27 at 12:38
So I have used the following environment variables but still not working:HOME=/home/cristian LOGNAME=cristian PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin SHELL=/bin/bash PWD=/home/cristian BASH_ENV=/home/cristian/.profile
â Cristian
Mar 27 at 17:08
1
I would do a test: Change your cron job from: 0 5 * * * /home/me/projects/execute-backup-from-container.sh to: 0 5 * * * /home/me/projects/execute-backup-from-container.sh >> ~/script_errors.log 2>&1 What will happen: the next time cron launches the job, error messages produced will be dumped into the text file script_errors.log. (change the path to the script_errors.log file to whatever seems appropriate, but make sure the path exists, but he file does not need to.)
â Art Hill
Mar 28 at 22:34
 |Â
show 1 more comment
up vote
1
down vote
Did you check that the file is set to be executable? Here is an example of marking a script as executable:
$ ls -l test.sh
-rw-r--r-- 1 ahill ahill 0 Mar 23 19:30 test.sh
$ chmod +x test.sh
$ ls -l test.sh
-rwxr-xr-x 1 ahill ahill 0 Mar 23 19:30 test.sh
The next thing to check is the environment. cron jobs inherit no environment by default. The "fix" is discussed here:
How can I run a cron command with existing environmental variables?
One of the reasons that the environment is a big deal is that cron might not even find bash! see: https://www.digitalocean.com/community/questions/why-is-cron-not-running-my-sh-script
If you still cannot figure it out, I would do a test: Change your cron job from:
0 5 * * * /home/me/projects/execute-backup-from-container.sh
to:
0 5 * * * /home/me/projects/execute-backup-from-container.sh >> ~/script_errors.log 2>&1
What will happen: the next time cron launches the job, error messages produced will be dumped into the text file script_errors.log. (change the path to the script_errors.log file to whatever seems appropriate, but make sure the path exists, though the file does not need to.)
I also noticed something in the OP that might be the real problem: the word "container." If the script is inside of a Docker container, then this is likely the solution:
https://www.ekito.fr/people/run-a-cron-job-with-docker/
This answer misses the point that the schedule used in the crontab is wrong.
â Kusalananda
Mar 24 at 15:29
You right... should have looked at that first... but I will leave it here as it might help someone else that is searching.
â Art Hill
Mar 26 at 15:06
Good point with the permissions. I had already put 777 toexecute-backup-from-container.sh
file before posting the question, so it does not help that, but I will check theenvironment variable
solution and let you know.
â Cristian
Mar 27 at 12:38
So I have used the following environment variables but still not working:HOME=/home/cristian LOGNAME=cristian PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin SHELL=/bin/bash PWD=/home/cristian BASH_ENV=/home/cristian/.profile
â Cristian
Mar 27 at 17:08
1
I would do a test: Change your cron job from: 0 5 * * * /home/me/projects/execute-backup-from-container.sh to: 0 5 * * * /home/me/projects/execute-backup-from-container.sh >> ~/script_errors.log 2>&1 What will happen: the next time cron launches the job, error messages produced will be dumped into the text file script_errors.log. (change the path to the script_errors.log file to whatever seems appropriate, but make sure the path exists, but he file does not need to.)
â Art Hill
Mar 28 at 22:34
 |Â
show 1 more comment
up vote
1
down vote
up vote
1
down vote
Did you check that the file is set to be executable? Here is an example of marking a script as executable:
$ ls -l test.sh
-rw-r--r-- 1 ahill ahill 0 Mar 23 19:30 test.sh
$ chmod +x test.sh
$ ls -l test.sh
-rwxr-xr-x 1 ahill ahill 0 Mar 23 19:30 test.sh
The next thing to check is the environment. cron jobs inherit no environment by default. The "fix" is discussed here:
How can I run a cron command with existing environmental variables?
One of the reasons that the environment is a big deal is that cron might not even find bash! see: https://www.digitalocean.com/community/questions/why-is-cron-not-running-my-sh-script
If you still cannot figure it out, I would do a test: Change your cron job from:
0 5 * * * /home/me/projects/execute-backup-from-container.sh
to:
0 5 * * * /home/me/projects/execute-backup-from-container.sh >> ~/script_errors.log 2>&1
What will happen: the next time cron launches the job, error messages produced will be dumped into the text file script_errors.log. (change the path to the script_errors.log file to whatever seems appropriate, but make sure the path exists, though the file does not need to.)
I also noticed something in the OP that might be the real problem: the word "container." If the script is inside of a Docker container, then this is likely the solution:
https://www.ekito.fr/people/run-a-cron-job-with-docker/
Did you check that the file is set to be executable? Here is an example of marking a script as executable:
$ ls -l test.sh
-rw-r--r-- 1 ahill ahill 0 Mar 23 19:30 test.sh
$ chmod +x test.sh
$ ls -l test.sh
-rwxr-xr-x 1 ahill ahill 0 Mar 23 19:30 test.sh
The next thing to check is the environment. cron jobs inherit no environment by default. The "fix" is discussed here:
How can I run a cron command with existing environmental variables?
One of the reasons that the environment is a big deal is that cron might not even find bash! see: https://www.digitalocean.com/community/questions/why-is-cron-not-running-my-sh-script
If you still cannot figure it out, I would do a test: Change your cron job from:
0 5 * * * /home/me/projects/execute-backup-from-container.sh
to:
0 5 * * * /home/me/projects/execute-backup-from-container.sh >> ~/script_errors.log 2>&1
What will happen: the next time cron launches the job, error messages produced will be dumped into the text file script_errors.log. (change the path to the script_errors.log file to whatever seems appropriate, but make sure the path exists, though the file does not need to.)
I also noticed something in the OP that might be the real problem: the word "container." If the script is inside of a Docker container, then this is likely the solution:
https://www.ekito.fr/people/run-a-cron-job-with-docker/
edited Mar 28 at 22:44
answered Mar 24 at 0:38
Art Hill
614
614
This answer misses the point that the schedule used in the crontab is wrong.
â Kusalananda
Mar 24 at 15:29
You right... should have looked at that first... but I will leave it here as it might help someone else that is searching.
â Art Hill
Mar 26 at 15:06
Good point with the permissions. I had already put 777 toexecute-backup-from-container.sh
file before posting the question, so it does not help that, but I will check theenvironment variable
solution and let you know.
â Cristian
Mar 27 at 12:38
So I have used the following environment variables but still not working:HOME=/home/cristian LOGNAME=cristian PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin SHELL=/bin/bash PWD=/home/cristian BASH_ENV=/home/cristian/.profile
â Cristian
Mar 27 at 17:08
1
I would do a test: Change your cron job from: 0 5 * * * /home/me/projects/execute-backup-from-container.sh to: 0 5 * * * /home/me/projects/execute-backup-from-container.sh >> ~/script_errors.log 2>&1 What will happen: the next time cron launches the job, error messages produced will be dumped into the text file script_errors.log. (change the path to the script_errors.log file to whatever seems appropriate, but make sure the path exists, but he file does not need to.)
â Art Hill
Mar 28 at 22:34
 |Â
show 1 more comment
This answer misses the point that the schedule used in the crontab is wrong.
â Kusalananda
Mar 24 at 15:29
You right... should have looked at that first... but I will leave it here as it might help someone else that is searching.
â Art Hill
Mar 26 at 15:06
Good point with the permissions. I had already put 777 toexecute-backup-from-container.sh
file before posting the question, so it does not help that, but I will check theenvironment variable
solution and let you know.
â Cristian
Mar 27 at 12:38
So I have used the following environment variables but still not working:HOME=/home/cristian LOGNAME=cristian PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin SHELL=/bin/bash PWD=/home/cristian BASH_ENV=/home/cristian/.profile
â Cristian
Mar 27 at 17:08
1
I would do a test: Change your cron job from: 0 5 * * * /home/me/projects/execute-backup-from-container.sh to: 0 5 * * * /home/me/projects/execute-backup-from-container.sh >> ~/script_errors.log 2>&1 What will happen: the next time cron launches the job, error messages produced will be dumped into the text file script_errors.log. (change the path to the script_errors.log file to whatever seems appropriate, but make sure the path exists, but he file does not need to.)
â Art Hill
Mar 28 at 22:34
This answer misses the point that the schedule used in the crontab is wrong.
â Kusalananda
Mar 24 at 15:29
This answer misses the point that the schedule used in the crontab is wrong.
â Kusalananda
Mar 24 at 15:29
You right... should have looked at that first... but I will leave it here as it might help someone else that is searching.
â Art Hill
Mar 26 at 15:06
You right... should have looked at that first... but I will leave it here as it might help someone else that is searching.
â Art Hill
Mar 26 at 15:06
Good point with the permissions. I had already put 777 to
execute-backup-from-container.sh
file before posting the question, so it does not help that, but I will check the environment variable
solution and let you know.â Cristian
Mar 27 at 12:38
Good point with the permissions. I had already put 777 to
execute-backup-from-container.sh
file before posting the question, so it does not help that, but I will check the environment variable
solution and let you know.â Cristian
Mar 27 at 12:38
So I have used the following environment variables but still not working:
HOME=/home/cristian LOGNAME=cristian PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin SHELL=/bin/bash PWD=/home/cristian BASH_ENV=/home/cristian/.profile
â Cristian
Mar 27 at 17:08
So I have used the following environment variables but still not working:
HOME=/home/cristian LOGNAME=cristian PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin SHELL=/bin/bash PWD=/home/cristian BASH_ENV=/home/cristian/.profile
â Cristian
Mar 27 at 17:08
1
1
I would do a test: Change your cron job from: 0 5 * * * /home/me/projects/execute-backup-from-container.sh to: 0 5 * * * /home/me/projects/execute-backup-from-container.sh >> ~/script_errors.log 2>&1 What will happen: the next time cron launches the job, error messages produced will be dumped into the text file script_errors.log. (change the path to the script_errors.log file to whatever seems appropriate, but make sure the path exists, but he file does not need to.)
â Art Hill
Mar 28 at 22:34
I would do a test: Change your cron job from: 0 5 * * * /home/me/projects/execute-backup-from-container.sh to: 0 5 * * * /home/me/projects/execute-backup-from-container.sh >> ~/script_errors.log 2>&1 What will happen: the next time cron launches the job, error messages produced will be dumped into the text file script_errors.log. (change the path to the script_errors.log file to whatever seems appropriate, but make sure the path exists, but he file does not need to.)
â Art Hill
Mar 28 at 22:34
 |Â
show 1 more comment
up vote
0
down vote
After keeping into account all the answers, the last issue was in the last line:
docker cp "$CONTAINER:/$FILE" backup-data/
The last line should have been
docker cp "$CONTAINER:/$FILE" docker-projects/mysql/backup-data/
Thank you all for your support.
add a comment |Â
up vote
0
down vote
After keeping into account all the answers, the last issue was in the last line:
docker cp "$CONTAINER:/$FILE" backup-data/
The last line should have been
docker cp "$CONTAINER:/$FILE" docker-projects/mysql/backup-data/
Thank you all for your support.
add a comment |Â
up vote
0
down vote
up vote
0
down vote
After keeping into account all the answers, the last issue was in the last line:
docker cp "$CONTAINER:/$FILE" backup-data/
The last line should have been
docker cp "$CONTAINER:/$FILE" docker-projects/mysql/backup-data/
Thank you all for your support.
After keeping into account all the answers, the last issue was in the last line:
docker cp "$CONTAINER:/$FILE" backup-data/
The last line should have been
docker cp "$CONTAINER:/$FILE" docker-projects/mysql/backup-data/
Thank you all for your support.
answered Mar 30 at 13:47
Cristian
265212
265212
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f433179%2fi-have-a-sh-script-how-to-run-it-using-crontab%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
@steeldriver you are right. If I want to make it every day should I have to put
*
instead of1
?â Cristian
Mar 23 at 23:52
If any of the answers solved your problem, please accept it by clicking the checkmark next to it. Thank you!
â Jeff Schaller
Mar 25 at 19:01
1
Also, you have a syntax error in the script:
$OUTPUT=...
should just beOUTPUT=...
â Jeff Schaller
Mar 27 at 12:38