Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

CRON Job Keeps Failing

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

You ever wonder how to backup Linux system files just like Windows System Restore?  Well you can use Timeshift in Linux to perform those similar action.  This tutorial will show you how to backup your system files and keep regular intervals. Note…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
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…
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.:

829 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