Operating System - HP-UX
1748265 Members
4059 Online
108760 Solutions
New Discussion юеВ

Re: Glance file is empty.

 
SOLVED
Go to solution
Eduard Pinales
Advisor

Glance file is empty.

Hi.

I have is scripts run in crontab.

########################################
#!/usr/bin/ksh
fecha=`date | awk '{print $1$2$3$4}`
/opt/perf/bin/glance -f /adm/scripts/glancemonitor$fecha.txt -iterations 1

But the file that generate this scripts is empty. i need help.

Regards,
13 REPLIES 13
Steven E. Protter
Exalted Contributor
Solution

Re: Glance file is empty.

Shalom,

Probably:
No variables are being submitted.
date or awk command are failing because cron jobs have no PATH set.

Set a PATH in your script.

See whence to find PATH

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Eduard Pinales
Advisor

Re: Glance file is empty.

thanks,

But the problem is that file is empty when scripts is finished by cron. all variable are ok, because the file have the date when script finished.
OFC_EDM
Respected Contributor

Re: Glance file is empty.

I've learned to listen to Steven :)

When you cron a job you dont have an environment.

So when the script executes via cron it will not know where date and awk are located. Thus, the commands will fail.

Try setting a path or explicity call the commands as below

#!/usr/bin/ksh
fecha=`/sbin/date | /usr/bin/awk '{print $1$2$3$4}`
/opt/perf/bin/glance -f /adm/scripts/glancemonitor$fecha.txt -iterations 1

Note the path to the date and awk commands may differ on your system as these paths are from my Tru64 system.

if you don't know the path to the command type:
which date
which awk

It will display where it finds the command...as long as it's in the PATH of the user you're logged in as.

Otherwise use the find command to find where they are.

Cheers
The Devil is in the detail.
Eduard Pinales
Advisor

Re: Glance file is empty.

I did. but the problem not solve.

-rw-r--r--1 root sys 0 Oct 23 11:20 glancemonitorThuOct2311:20:00.txt

The script look as follow .
fecha=`/usr/bin/date | /usr/bin/awk '{print $1$2$3$4}`
/opt/perf/bin/glance -f /adm/scripts/glancemonitor$fecha.txt -iterations 1

Regards
Torsten.
Acclaimed Contributor

Re: Glance file is empty.

I think the problem is somewhere else.

Re-direct the error channel to a file!

I assume something like this:

# export TERM=xx
# glance -f /tmp/t1 -iterations 1

Welcome to Glance


Sorry, I don't know anything about your "xx" terminal.





IMHO your result will be similar!

Hope this helps!
Regards
Torsten.

__________________________________________________
There are only 10 types of people in the world -
those who understand binary, and those who don't.

__________________________________________________
No support by private messages. Please ask the forum!

If you feel this was helpful please click the KUDOS! thumb below!   
Torsten.
Acclaimed Contributor

Re: Glance file is empty.

See

man glance

on how to run it in background.

Hope this helps!
Regards
Torsten.

__________________________________________________
There are only 10 types of people in the world -
those who understand binary, and those who don't.

__________________________________________________
No support by private messages. Please ask the forum!

If you feel this was helpful please click the KUDOS! thumb below!   
Torsten.
Acclaimed Contributor

Re: Glance file is empty.

Well, it's the output channel, not the error channel.

# glance -f /tmp/t1 -iterations 1 >/tmp/t2
# more /tmp/t2
Sorry, I don't know anything about your "xx" terminal.

Welcome to Glance


You will probably find related massages in

# more /var/adm/cronlog

Hope this helps!
Regards
Torsten.

__________________________________________________
There are only 10 types of people in the world -
those who understand binary, and those who don't.

__________________________________________________
No support by private messages. Please ask the forum!

If you feel this was helpful please click the KUDOS! thumb below!   
Eduard Pinales
Advisor

Re: Glance file is empty.

the problem is same. The file is empty when the cron run the script.
Torsten.
Acclaimed Contributor

Re: Glance file is empty.

I'm not sure if you understand - a cronjob has no terminal


-> glance will not run!

See

man glance

on how to run glance without a terminal (in background).

Hope this helps!
Regards
Torsten.

__________________________________________________
There are only 10 types of people in the world -
those who understand binary, and those who don't.

__________________________________________________
No support by private messages. Please ask the forum!

If you feel this was helpful please click the KUDOS! thumb below!