LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-04-2020, 02:19 AM   #1
Dain_Bramage
Member
 
Registered: Mar 2019
Posts: 46

Rep: Reputation: Disabled
Cron job not running


Hi,

I was wondering if someone could tell me why the below command will run in terminal but not as a cron job.

Code:
0 3 * * * /usr/bin/mysqldump -u mike nextcloud > /home/mike/Backups/nextcloud-$(date +%d%b%y).sql
I was following directions here.

Thank you.

Last edited by Dain_Bramage; 05-04-2020 at 02:43 AM.
 
Old 05-04-2020, 02:44 AM   #2
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,670

Rep: Reputation: Disabled
Does it require password for user mike to connect to the database?
 
Old 05-04-2020, 02:50 AM   #3
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,830

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
you ought to send stderr into a file too (because the error message is probably there). Or it is mailed to the owner of this cron.
 
Old 05-04-2020, 02:56 AM   #4
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 2,149

Rep: Reputation: 449Reputation: 449Reputation: 449Reputation: 449Reputation: 449
check out links below might help:

https://superuser.com/questions/1655...-use-mysqldump

https://stackoverflow.com/questions/...assword-prompt

As pointed out by Shruggy, you might need the password.

Have you tried putting that command to a ".sh" script and run it manually, to check if it works or not?
 
Old 05-04-2020, 04:04 AM   #5
Dain_Bramage
Member
 
Registered: Mar 2019
Posts: 46

Original Poster
Rep: Reputation: Disabled
It was the date.

According to this post here

Quote:
If your crontab command has a % symbol in it, cron tries to interpret it. So if you were using any command with a % in it (such as a format specification to the date command) you will need to escape it.
Code:
* 3 * * * /usr/bin/mysqldump -u mike nextcloud > /home/mike/Backups/nextcloud-$(date +\%d\%b\%y).sql
worked. It never ceases to amaze me the myriad of different ways cron can trip you up.
 
1 members found this post helpful.
Old 05-05-2020, 01:56 AM   #6
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 2,149

Rep: Reputation: 449Reputation: 449Reputation: 449Reputation: 449Reputation: 449
Cool

Quote:
Originally Posted by Dain_Bramage View Post
It was the date.

According to this post here



Code:
* 3 * * * /usr/bin/mysqldump -u mike nextcloud > /home/mike/Backups/nextcloud-$(date +\%d\%b\%y).sql
worked. It never ceases to amaze me the myriad of different ways cron can trip you up.

Cool, glad you found the issue and Thanks for sharing the solution. Hopefully this will help others too. Cheers!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Cron Job Not Running - Looks Like Cron Tried Noble User Linux - Newbie 7 10-26-2014 10:26 AM
how to abort cron if the previous cron job not yet finished? Winanjaya Linux - Newbie 2 05-22-2012 06:44 PM
linux cron job duplicate job question cpthk Linux - Newbie 4 09-11-2009 08:52 PM
adding a perl script to cron.daily / cron.d to setup a cron job CrontabNewBIE Linux - Software 6 01-14-2008 08:16 AM
cron not working from crontab nor form /etc/cron/cron.d. What did SuSE change? JZL240I-U SUSE / openSUSE 11 01-04-2007 01:57 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:52 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration