Issue in running a command line utility in CRON

Hi Everyone!

I am facing an issue in running a command line utility from the CRON.

This utility displays IPC statistics on UNIX message queues: The "queue name" and the "count" of messages in the queue.
When running this utility from prompt, it will provide an output on the screen, like the below:

>ABC

====================================================
Line  Queue Name         In-queue     %Used  Queue-Size  Status
=====================================================
   1  q1                              0        0%           1             RdBlk
   2  q2                              0        0%           1             RdBlk

BUT, when I schedule this command in the CRON, like below, it gives out nothing:

>crontab -l
* * * * * /path/to/utility/ABC ) >>/tmp/output
>cat /tmp/output
>

Request your advise on the issue: why the same command is not outputing the required statistics when used in CRON.

Basically I want to process the output of the command in a script to prepare reports/ setting up alerts etc, and use this script in the CRON.

Please let me know what more info is required.

NOTE: The above utility is supplied by a software vendor.

Thanks in Advance!
VS

When I run the command:

/path/to/utility/ABC ) >>/tmp/output

I get a syntax error at the ) . What shell are you using that allows you to run that command?

What OS are you using?

If the seemingly extraneous closing parenthesis isn't your problem, jobs started by cron have a much more restricted environment than what you get when you login to the system. Does /path/to/utility/ABC depend on any environment variables? Is it a shell script? If it is a shell script, do the files it needs to run exist in the directory where cron runs your script? If it is a shell script does cron start it using a shell compatible with the shell you expect to run your script?

1 Like

Hi Don,

Sorry for the typo while writing here: it should have been:

/path/to/utility/ABC  >>/tmp/output

But that is not the issue.

The OS: HP-UX
The command line utility is an executable file (ELF-32).

As for the env. variables, I do execute a .profile which might contain the required ones, some think like:

>crontab -l
* * * * * . .profile; /path/to/utility/ABC >>/tmp/output

But it gives no output.

As you mentioned, the CRON provide a more restrictive env., than actually logging in, can you please guide on how to make sure that proper env. is available to CRON so proper execution of that utility takes place?

This is a very common problem that has been answered many times before. Start with this FAQ on cron and crontab and follow links from there.

If that still doesn't answer your questions, post your script so we can have a chance at guessing what is wrong.

1 Like

Hi Don,

Thanks for providing the excellent cue about the env settings difference with respect cron and when one logs in.
Added the paths etc. and the utility works fine as required!

Thanks again :slight_smile: