Cron issue: Why cronjob does not work when % sign is used in RHEL?

Solution Verified - Updated -

Issue

  • I have following line in a cron file:
24 * * * * /bin/cp /etc/<file-name> "/tmp/<file-name>.txt.$(date +%Y%m%d%H%M%S)"
  • Getting below errors after setting above cronjob
/bin/sh: -c: line 0: unexpected EOF while looking for matching `)'
/bin/sh: -c: line 1: syntax error: unexpected end of file
  • What is wrong with the above cronjob?

Environment

  • Red Hat Enterprise Linux (RHEL) 4
  • Red Hat Enterprise Linux (RHEL) 5
  • Red Hat Enterprise Linux (RHEL) 6
  • Red Hat Enterprise Linux (RHEL) 7
  • crond

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.