Crontab Syntax Error
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business eof in backquote substitution shell Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation syntax error: eof in backquote substitution in shell script Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like perl syntax error: eof in backquote substitution you, helping each other. Join them; it only takes a minute: Sign up CRONTAB syntax error up vote 26 down vote favorite 5 Herer is my CRONTAB file (Ubuntu 10.10): 57 1 * * 2-6 ET=`date --date syntax error: eof in backquote substitution cron 'yesterday'+%Y%m%d`;echo $ET Even The syntax color indicate that something is wrong. and there is this error: Subject: Cron
Crontab Log
oldest votes up vote 62 down vote accepted Cron needs to escape the % sign - http://www.hcidata.info/crontab.htm Try it with a backslash: 57 1 * * 2-6 ET=`date --date 'yesterday' +\%Y\%m\%d`;echo $ET share|improve this answer edited Sep 5 '13 at 8:17 zmo 15.6k12255 answered Aug 15 '11 at 18:13 brightlancer 1,42986 Yeah it works! But one space is needed between 'yeaterday' and +.57 5 * * 2-6 ET=date --date 'yesterday' +\%Y\%m\%d; –DocWiki Aug 15 '11 at 18:56 add a comment| Your Answer draft saved draft discarded Sign up or log in Sign up using Google Sign up using Facebook Sign up using Email and Password Post as a guest Name Email Post as a guest Name Email discard By posting your answer, you agree to the privacy policy and terms of service. Not the answer you're looking for? Browse other questions tagged bash ubuntu cron syntax-error crontab or ask your own question. asked 5 years ago viewed 7749 times active 3 years ago Related 88How to specify in crontab by what user to run script?191Restarting cron after changing crontab file?0Crontab syntax error while using mysqldump50Crontab Day of the Week syntax3Can't make crontab work2ssconvert from www-data cron on a headless server fails with various errors-1Php CronTab not showing any errors0cron error bad minute + errors in crontab file can't install in ubuntu-1Crontab
Start here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about
Date In Crontab
Stack Overflow the company Business Learn more about hiring developers or posting ads with us Server Fault Questions Tags Users Badges Unanswered Ask Question _ Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute: Sign up Here's how it works: Anybody can ask a question Anybody can answer The best answers are voted up and rise to the top http://stackoverflow.com/questions/7068759/crontab-syntax-error What's wrong with my cronjob syntax, I'm trying to use a backtick (`)? up vote 19 down vote favorite 1 Here's what I'd like to automate: 00 08 * * * psql -Uuser database < query.sql | mail somone@null.com -s "query for `date +%Y-%m-%dZ%I:%M`" Here's the error message: /bin/sh: -c: line 0: unexpected EOF while looking for matching ``' /bin/sh: -c: line 1: syntax error: unexpected end of file cron syntax http://serverfault.com/questions/84430/whats-wrong-with-my-cronjob-syntax-im-trying-to-use-a-backtick share|improve this question asked Nov 13 '09 at 15:05 Terry Lorber 21339 1 Apart from the giving error consider to put this in a schell script. It will pretend the crontab to be clumsy and you can add comments and config to your script file. –PeterMmm Nov 13 '09 at 15:09 add a comment| 2 Answers 2 active oldest votes up vote 43 down vote accepted From crontab(5): The ``sixth'' field (the rest of the line) specifies the command to be run. The entire command portion of the line, up to a newline or % character, will be executed by /bin/sh or by the shell specified in the SHELL variable of the crontab file. Percent-signs (%) in the command, unless escaped with backslash (), will be changed into newline characters, and all data after the first % will be sent to the command as standard input. There is no way to split a single command line onto multiple lines, like the shell's trailing "\". Just add backslashes before % signs: 00 08 * * * psql -Uuser database < query.sql | mail somone@null.com -s "query for `date +\%Y-\%m-\%dZ\%I:\%M`" share|improve this answer answered Nov 13 '09 at 15:19 Juliano 4,2521925 Excellent. Thanks. –Terry Lorber Nov 13 '09 a
Tips 46 Comments Setting up cron jobs in Unix and Solaris cron is a unix, solaris utility that allows tasks to be automatically run in the background at http://www.adminschoice.com/crontab-quick-reference regular intervals by the cron daemon. These tasks are often termed as cron jobs in unix , solaris. Crontab (CRON TABle) is a file which contains the schedule of cron entries to be run and at specified times. This document covers following aspects of Unix cron jobs 1. Crontab Restrictions 2. Crontab Commands 3. Crontab file - syntax 4. Crontab Example 5. Crontab Environment syntax error 6. Disable Email 7. Generate log file for crontab activity 1. Crontab Restrictions You can execute crontab if your name appears in the file /usr/lib/cron/cron.allow. If that file does not exist, you can use crontab if your name does not appear in the file /usr/lib/cron/cron.deny. If only cron.deny exists and is empty, all users can use crontab. If neither file exists, only the root user eof in backquote can use crontab. The allow/deny files consist of one user name per line. 2. Crontab Commands export EDITOR=vi ;to specify a editor to open crontab file. crontab -e Edit your crontab file, or create one if it doesn't already exist. crontab -l Display your crontab file. crontab -r Remove your crontab file. crontab -v Display the last time you edited your crontab file. (This option is only available on a few systems.) 3. Crontab file Crontab syntax : A crontab file has five fields for specifying day , date and time followed by the command to be run at that interval. * * * * * command to be executed - - - - - | | | | | | | | | +----- day of week (0 - 6) (Sunday=0) | | | +------- month (1 - 12) | | +--------- day of month (1 - 31) | +----------- hour (0 - 23) +------------- min (0 - 59) * in the value field above means all legal values as in braces for that column. The value column can have a * or a list of elements separated by comma