Issue in running a command line utility in CRON


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Issue in running a command line utility in CRON
# 1  
Old 08-14-2014
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:

Code:
>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:

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

Code:
>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

Last edited by Don Cragun; 08-15-2014 at 12:00 AM.. Reason: Change ICODE tags to CODE tags.
# 2  
Old 08-15-2014
When I run the command:
Code:
/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?
This User Gave Thanks to Don Cragun For This Post:
# 3  
Old 08-15-2014
Hi Don,

Sorry for the typo while writing here: it should have been:
Code:
/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:

Code:
>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?

Last edited by rbatte1; 08-15-2014 at 06:56 AM.. Reason: Changed main block in ICODE tags to just CODE tags
# 4  
Old 08-15-2014
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.
This User Gave Thanks to Don Cragun For This Post:
# 5  
Old 08-15-2014
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 Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Issue Running UNIX process from CRON !!

Experts, Not sure whether the problem described here is related with Unix or is it with Oracle Installation. Here is the description of the issue: A new Unix server is setup as a part of Unix and Oracle upgradation activity for one of the Application, I work on. One strange thing is... (2 Replies)
Discussion started by: Oracle_User
2 Replies

2. Shell Programming and Scripting

Getting issue while running it from cron while manually working fine

Hello, I am working one one script where I am using the below code which is using to connect with MKS client when I run my script manually it works effiecently i.e. it connects with MKS client but when I run it from CRON it doesn't connect. 1)Can some one tell when it is running from cron... (1 Reply)
Discussion started by: anuragpgtgerman
1 Replies

3. UNIX for Dummies Questions & Answers

FTP command-line utility usage

Hi, Using command-line utility "ftp or sftp", I want to transfer files across Windows and UNIX. Can you please tell me from where I need to connect to ftp and how do I specify the hostname, credentials and how do I get and put files between DOS and UNIX? Please provide me as much... (10 Replies)
Discussion started by: Dev_Dev
10 Replies

4. Shell Programming and Scripting

DB Access Command Line Utility

To read/write to a DB from Java or Perl, you usually have to install/reference several drivers and write a whole bunch of boilerplate DB access code. I'm curious if someone has written a command line utility for Unix/Linux for simple database access for the major providers, something like: ... (3 Replies)
Discussion started by: furashgf
3 Replies

5. Linux

The dot command-line utility?

Hi, What else is the dot used beside relative filepaths in bash? Is it a shell utility as well? No man entry for dot (.)... (3 Replies)
Discussion started by: varelg
3 Replies

6. Shell Programming and Scripting

Cron job giving error while running SSH command

Hi All, The script which i am using to SSH to remote server is working fine when i run is using ./ but when cron runs it it gives error that "ssh: not found" please help!!! (3 Replies)
Discussion started by: visingha
3 Replies

7. Programming

top command line utility

I'm writing a monitoring application. I'd like to periodically get the information provided by the 'top' command line utility from within my code and write the output of 'top' to a file. Wondering if anyone has already done something like this. Doing system("top > someFile"); does not create... (6 Replies)
Discussion started by: antoniomorandi
6 Replies

8. Programming

command line socket read utility

HI I have a messaging s/w daemon(TIBCO rvrd) provided by vendor which will accept connections from various clients and routes messages to the destinations. In order to route it internally uses two ports(one tcp adn one udp). I want to know on which port(tcp/udp) it is transmitting... (3 Replies)
Discussion started by: axes
3 Replies

9. SuSE

inconsistent ls command display at the command prompt & running as a cron job

Sir, I using the following commands in a file (part of a bigger script): #!/bin/bash cd /opt/oracle/bin ls -lt | tail -1 | awk '{print $6}' >> /tmp/ramb.out If I run this from the command prompt the result is: 2007-05-16 if I run it as a cron job then... (5 Replies)
Discussion started by: rajranibl
5 Replies
Login or Register to Ask a Question