Solved

CRON Job Keeps Failing

Posted on 2011-03-16
5
425 Views
Last Modified: 2012-05-11
mysqldump -u root -ppassword theipb | gzip -c > /home/domain/public_html/_db_backups/$(date "+%Y%M%d%H%m").theipb.sql.gz

The above command runs fine from ssh, but when added as a cron job on simple control panel it never completes.  Is there a syntax error in it for the control panel?
0
Comment
Question by:N R
5 Comments
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 500 total points
ID: 35149460
Hi,

a particularity of cron is that you must escape the percent signs (%) with a backslash (\%).

Next, you should always specify the full path of any executable.

Finally, please be aware that cron doesn't start a true login shell, so the user's shell initialization profiles will not be executed!

wmp


0
 

Expert Comment

by:mjagdis
ID: 35149514
Unescaped '%'s are converted to newlines and everything after the first is sent to the command as standard input. See the man page for crontab(5).
0
 
LVL 40

Expert Comment

by:omarfarid
ID: 35150443
For crontab jobs to run successfully, and in your case, please do the following:

create a shell script file
set required env variables in it (or you may source a .profile file using . /path/to/.profile)
add the above command to it (use full pathnames for command, etc)
make the script executable
add it as a crontab job by referring to its full pathname

you may read the crontab log file to check for error messages , or you mar redirect standard error to a file ( 2> /path/to/mylogfile)
0
 
LVL 40

Expert Comment

by:omarfarid
ID: 35150473
you may use >> & 2>> for redirection of output and standard error rather than > & 2> to accumulate output and error messages
0
 
LVL 7

Expert Comment

by:droyden
ID: 35171184
Make sure you define your PATH var in your crontab to ensure the.binaries are found
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Problem with SqlConnection 4 159
Linux tcp ports listening for testing 4 44
Mysql sync between 3-4 mysql db 4 23
su - oracle could not open session 6 47
In my business, I use the LTS (Long Term Support) versions of Linux. My workstations do real work, and so I rarely have the patience to deal with silly problems caused by an upgraded kernel that had experimental software on it to begin with from a r…
The purpose of this article is to show how we can create Linux Mint virtual machine using Oracle Virtual Box. To install Linux Mint we have to download the ISO file from its website i.e. http://www.linuxmint.com. Once you open the link you will see …
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now