UNIX command in cron not working


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting UNIX command in cron not working
# 1  
Old 05-06-2013
UNIX command in cron not working

the following unix command gives me the number of records avaiable in my application

Code:
/navs/sys/appl/bin/record list

This gives number of rows and colums. I want to generate one text file everyday at 6:10 AM using cron
So I added following entery into crontable

Code:
#Generate record file at 6:10 AM daily

10 06 * * * /navs/sys/appl/bin/record list > /bto/usr/appuser/record.txt


record.txt file is created at 6:10 AM but it is empty. Smilie

When i run the above command manualy it is successfuly created and contain data
Can anyone help me Please I want to do it by cron..
# 2  
Old 05-06-2013
Is "list" a file? Is so, the reason it is not working is because the command cannot find the file. If "list" is a file, try using an absolute path.

Also, try redirecting the stderr with 2> /tmp/error.log and see what shows up there.
# 3  
Old 05-07-2013
"list" is not a file. I checked at the path
Code:
/navs/sys/appl/bin/

There i found the script named record*. but no "list".

i tried to execute this
Code:
/navs/sys/appl/bin/record

but it says
Code:
2013-05-07 05:53:49  4108        : record: Not a valid record issued.

i get required information only when i use
Code:
/navs/sys/appl/bin/record list

I am unable to find what that "list" means. And Also why this command is not running in cron. Smilie

Experts Please help me. I want to run it into cron.
# 4  
Old 05-07-2013
What is the output of
Code:
file /navs/sys/appl/bin/record

# 5  
Old 05-07-2013
I checked the output of
Code:
/navs/sys/appl/bin/record

it is giving following error
Code:
 2013-05-07 14:07:49 4108        : record : Not a valid record issued

I also tried to open and see that record* script. But it opens with the unreadable characters. I think its a binary file.

and i think "list" is the argument that is passed to this file.
# 6  
Old 05-07-2013
What if you try to get more information about the command:
Code:
/navs/sys/appl/bin/record --help
/navs/sys/appl/bin/record -h
man record

You can't effectively use a command without knowing a little about it.

If no documentation, maybe there is some environmental variable set for your interactive session that is not set for CRON. You might need to figure out which variable that is and set it in the crontab.
# 7  
Old 05-07-2013
It is a binary file. I guess you fired just /navs/sys/appl/bin/record instead of file /navs/sys/appl/bin/record as fpmurphy suggested.
Please note file is a command and we didn't mean anything else.

Try to find out if record uses some environment variables. May be refer to its manual/document if available or ask your colleagues.

Meanwhile,
Check and see the current environment setting from which you are executing command manually with env

Plus, as other's suggested, update the cron entry as

Code:
10 06 * * * /navs/sys/appl/bin/record list > /bto/usr/appuser/record.txt 2>&1

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Homework & Coursework Questions

UNIX head command not working?

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Write a script that allows the user to print the first n lines or the last n lines of every file in the... (18 Replies)
Discussion started by: lukefrost96
18 Replies

2. Shell Programming and Scripting

UNIX command for checking the cron job failures?

Hi- I need to set a mail trap for checking the cron job filures in a server. I have many cron jobs running in our server. What unix command will identify the failed cron jobs? Your thoughts please!!!!! (6 Replies)
Discussion started by: ChandruBala73
6 Replies

3. Shell Programming and Scripting

sed Command not working in AIX UNIX

Hi 1st problem -------------- i have this sed command in my unix script which replaces new line and carriage return in a line with the string "&#xA" the script works fine in Linux 3.0.101-0.5, but not in AIX 1 7 , the "s/\r/\&#xA/g" replacement, replaces all the character "r" in the file.... (3 Replies)
Discussion started by: maximus_jack
3 Replies

4. Shell Programming and Scripting

Script not working in cron but working fine manually

Help. My script is working fine when executed manually but the cron seems not to catch up the command when registered. The script is as follow: #!/bin/sh for file in file_1.txt file_2.txt file_3.txt do awk '{ print "0" }' $file > tmp.tmp mv tmp.tmp $file done And the cron... (2 Replies)
Discussion started by: jasperux
2 Replies

5. Shell Programming and Scripting

Script is not working from cron while working manually

Hello, I am facing a very strange problem when I run my script manuallu ./Fetchcode which is using to connect with MKS integrity from linux end it workks fine but when I run it from cron it doesn't work.Can someone help me 1) How could I check my script when it is running from cron like... (3 Replies)
Discussion started by: anuragpgtgerman
3 Replies

6. Shell Programming and Scripting

cp command not working in script for non unix file

Piece of code in sh file ------------------------ echo "lalit test bef" which cp cp $l_options $srcdirfile $destdirfile echo "lalit test after" echo "**************************options below" echo "loption $l_options" echo "src $srcdirfile" echo "destinat... (3 Replies)
Discussion started by: lalitpct
3 Replies

7. Shell Programming and Scripting

sudo command is not working inside a script when placed in cron

Hi All, i have a cron entry like 0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57 * * * * /amex/sssmonitor/dss_chk.ksh and the script is like #!/bin/ksh file=`uname -n` > /sunmast/projects/oasis/COREDEV/Dss$file.log > /tmp/output_sss today=`date` varb=`ps -ef | grep... (5 Replies)
Discussion started by: usha rao
5 Replies

8. Shell Programming and Scripting

Sudo command not working with cron job.

Hello, I have written a script that has a sudo command to change file permissions within it. When I run the script manually, the sudo command inside of it works fine. When the script is run through crontab I get the error "cron: not found". It the same user profile that I am using... (6 Replies)
Discussion started by: WhotheWhat
6 Replies

9. Shell Programming and Scripting

Grep command is not working when put into cron

Hi, I worte a script which runs perfect when i execute it manually. But when i scheduled into cron the grep command alone is not working. the sample script, /usr/bin/grep FTP $subfile > /tmp/tfsrec.dat tfs=`echo $?` if then echo "FTP FOUND" else echo "FTP NOT FOUND" Where... (5 Replies)
Discussion started by: thiru_cs
5 Replies
Login or Register to Ask a Question