Solved

CRON Job Keeps Failing

Posted on 2011-03-16
5
419 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

743 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

11 Experts available now in Live!

Get 1:1 Help Now