Technical article 110519

I get a "date: format conversion error" when using the date(C) command from within cron(C).

OpenServer 5.0.0OpenServer 5.0.2OpenServer 5.0.4OpenServer 5.0.5

Written · Last revised

Problem

I am trying to use the date(C) command from cron(C) but I get an error emailed to me from the cron daemon saying:

date: format conversion error
'
+++++++++++++++++++++++++++++++++++++++++++++++++

Cron: The previous message is the standard output and standard error of one of your cron commands.

The date(C) syntax I am using is:

date +%d/%m/%y

It works from the command line and it used to work on my SCO OpenServer Release 5.0.2 or 5.0.4 system before the installation of Support Level Supplement (SLS) OSS601A.

Cause

The crontab(C) manual page says:
             The sixth field is a string that is executed by the shell at the
             specified time (using time(S) format). A "%" in this field is
             translated into a newline character. Only the first line (up to
             a "%" or end-of-line) of the command field is executed by the
	     shell. The other lines are made available to the command as
             standard input.

The version of cron(C) in SCO OpenServer 5.0.2 and 5.0.4 did not behave in the fashion described above and was fixed in SLS OSS601A.

Solution

If you want to use date(C) with the +format syntax, SCO recommends that you run date from a shell script and call the shell script from within your crontab file.

A sample shell script called $HOME/date.sh could contain:

#!/bin/sh
date +%d/%m/%y

Once you have created the shell script, you should make it executable using chmod(C) as follows:

chmod +x $HOME/date.sh

Then save your current crontab entries using:

crontab -l > cron.file

Edit the crontab file and add an entry for your shell script.

From the Xinuos technical article database, record 110519. Reproduced with permission. The original is at www.sco.com/ta/110519, which is reachable but blocked from search engines. Xinuos marks this article against a retired product line. That refers to the product’s lifecycle, not to whether the advice still works — plenty of it still applies to running systems.

Next step

Need this fixed rather than explained?

Tell us the release, what the system runs and what it is doing. We will reply by email with what we would do next.

  • You deal with the people who do the work
  • No obligation, and no upgrade required before we will help
  • We tell you plainly if something is not worth doing

Send an enquiry

We reply by email. If a server is down, say so in the first line. You can also write to help@scoexpert.com.