cron output = 0 bytes


 
Thread Tools Search this Thread
Operating Systems Solaris cron output = 0 bytes
# 1  
Old 06-28-2005
cron output = 0 bytes

I have a cron job set to run a script everyday. If I run the script out side of cron it runs correctly. If cron runs the script is produces a 0 byte file and it puts the output in the / directory. The script is set to put the output in a specific directory. Any help would be appreciated.
# 2  
Old 06-28-2005
check your 'script' for any type of the environment variables and make sure those are accessible from within cron.
# 3  
Old 06-28-2005
I thought I read that cron needs to be able to see the path to the script or parameteres within the script. Is this set in /etc/default/cron.

Below is a copy of the script, (message_log.pl).

# more message_log.pl
#!/usr/local/bin/perl
#! /usr/bin/ksh
#MagicStore message log utility
( $sec, $min, $hour, $mday, $mon, $year,, ) = localtime();
$today = sprintf( "%04d%02d%02d", ( $year + 1900 ), ( $mon + 1 ), $mday );
print "Parsing through message log...........\n";
sleep 2;
system("mkdir log") if (! -d "./log");
InstallScript();

system("./dl.csh > /images_1/messages/dl.out");
system("./dl.awk /images_1/messages/dl.out > /images_1/messages/dl1.out");
#---------------Set the line below to what type of message you want to trap-----
---------
system("grep PAT_INCONSISTENT /images_1/messages/dl1.out>$today.message.log");
system("rm -f /images_1/messages/dl.out");
system("rm -f /images_1/messages/dl1.out");
print "Your file named $today.message.log is ready for viewing\n";

sub InstallScript
{

unlink("/images_1/messages/dl.csh");
open(CSH,">/images_1/messages/dl.csh");
print CSH "#!/bin/csh\n";
print CSH "source ~work/.cshrc\n";
print CSH "source /home/sn_root/bin/apc/apc_env.csh\n";
print CSH "/home/sn_root/bin/apc/apc << EOF\n";
print CSH "4\n11\n5\n1\nEOF\n";
close(CSH);
system("chmod a+rwx /images_1/messages/dl.csh");

unlink("/images_1/messages/dl.awk");
open(AWK,">/images_1/messages/dl.awk");
print AWK "#!/usr/bin/nawk -f\n";
print AWK 'BEGIN { FS="\n";';
print AWK 'RS = "" }';
print AWK "\n";
print AWK "{\n";
print AWK 'if(sub(/^ date *:/,"",$1)) {';
print AWK "\n";
print AWK 'sub(/^ message *:/,"",$2)';
print AWK "\n";
print AWK 'print $1,$2';
print AWK "\n";
print AWK "\n}\n}";
close(AWK);
system("chmod a+rwx /images_1/messages/dl.awk");

}
# 4  
Old 06-28-2005
your perl is making some assumptions that might not hold true under cron - in terms of file paths:

system("mkdir log") if (! -d "./log");
system("./dl.csh > /images_1/messages/dl.out");
system("./dl.awk /images_1/messages/dl.out > /images_1/messages/dl1.out");
print CSH "source ~work/.cshrc\n";
# 5  
Old 06-28-2005
Where and how do i modify the paths in cron. Or do i need to modify the script?
# 6  
Old 06-28-2005
Quote:
Originally Posted by mbattreall
Where and how do i modify the paths in cron. Or do i need to modify the script?
I'd modify the script to make it aware of:
  1. the directory where the script resides so that things like './dl.csh' can be resolved.
  2. the '~work/.cshrc'
# 7  
Old 06-28-2005
Once cron references the script shouldn't the script already know where to go? Below is a listing from cron and it is already in the correct directory?

30 07 * * * /images_1/messages/message_log.pl
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script - entered input(1-40 bytes) needs to be converted exactly 40 bytes

hello, suppose, entered input is of 1-40 bytes, i need it to be converted to 40 bytes exactly. example: if i have entered my name anywhere between 1-40 i want it to be stored with 40 bytes exactly. enter your name: donald duck (this is of 11 bytes) expected is as below - display 11... (3 Replies)
Discussion started by: shravan.300
3 Replies

2. UNIX for Dummies Questions & Answers

X bytes of 0, Y bytes of random data, Z bytes of 5, T bytes of 1. ??

Hello guys. I really hope someone will help me with this one.. So, I have to write this script who: - creates a file home/student/vmdisk of 10 mb - formats that file to ext3 - mounts that partition to /mnt/partition - creates a file /mnt/partition/data. In this file, there will... (1 Reply)
Discussion started by: razolo13
1 Replies

3. Shell Programming and Scripting

Output only first 400 bytes of a huge text file

How do I output only the first 400 bytes of a huge text file to a new file. It has to be unmodified so no added invisible characters. Many thanks..... (3 Replies)
Discussion started by: garethsays
3 Replies

4. Programming

Copying 1024 bytes data in 3-bytes chunk

Hi, If I want to copy a 1024 byte data stream in to the target location in 3-bytes chunk, I guess I can use the following script. dd bs=1024 count=3 if=/src of=/dest But, I would like to know, how to do it via a C program. I have tried this with memcpy(), that did not help. (3 Replies)
Discussion started by: royalibrahim
3 Replies

5. Shell Programming and Scripting

Error PHP Fatal error: Allowed memory size of 67108864 bytes exhausted(tried to allocate 401 bytes)

While running script I am getting an error like Few lines in data are not being processed. After googling it I came to know that adding such line would give some memory to it ini_set("memory_limit","64M"); my input file size is 1 GB. Is that memory limit is based on RAM we have on... (1 Reply)
Discussion started by: elamurugu
1 Replies

6. Red Hat

Cron task output is 0, script output is OK

I have the following cron task set to run every 15 minutes to ascertain how many users are in the system and append the result to the log. /home/pronto/cus/whoisinc >> /home/pronto/cus/whoisin.log This is the whoisinc script date +"%d-%m-%Y,%k:%M,Pronto Users,`prowho -s | grep -v... (1 Reply)
Discussion started by: scottm
1 Replies

7. Solaris

how we can calculate this bytes(55207936) in to MB(output=26957)

root@erpdevserver $ vxassist -g devdg maxsize Maximum volume size: 55207936 (26957Mb) This is the output in vxvm(3.1).. my question is how we can calculate this bytes(55207936) in to MB(output=26957) or in GB.plz tell how to calculate (2 Replies)
Discussion started by: tv.praveenkumar
2 Replies

8. UNIX for Dummies Questions & Answers

cron output error

I am attempting to run a cron job, however, I receive this cron output error: Error: of parameter : xxxxx does not make a valid output file. What causes this? (4 Replies)
Discussion started by: AM1234
4 Replies

9. Shell Programming and Scripting

Remove first N bytes and last N bytes from a binary file on AIX.

Hi all, Does anybody know or guide me on how to remove the first N bytes and the last N bytes from a binary file? Is there any AWK or SED or any command that I can use to achieve this? Your help is greatly appreciated!! Best Regards, Naveen. (1 Reply)
Discussion started by: naveendronavall
1 Replies

10. UNIX for Dummies Questions & Answers

Cron + Script = No Output?

I've got an *extremely* simple script I want to run every minute: #!/bin/sh ping -c 1 192.168.1.20 > ~/onlinestatus.txt So, the script is called "status", it's executable, and in the correct path, etc. In a terminal window (I'm using Mac OS X), I can type status, and it will create... (4 Replies)
Discussion started by: jmf77
4 Replies
Login or Register to Ask a Question