Solved

CRON Job Keeps Failing

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
mysql between clause 2 21
possible to record changes (trigger I think) msql 11 34
awk sed 8 39
INDEX does not make a difference, why? 10 44
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 …
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
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.:
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.

813 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

13 Experts available now in Live!

Get 1:1 Help Now