Measure thread execution (in C, unix)


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Measure thread execution (in C, unix)
# 15  
Old 03-24-2011
That is two scripts, I hope, or what is the second #! for?

exit 0 is the free default implicitly, you just need it for other returns.

No, I meant put in the wrapper to collect any wandering output that occurs under cron. The () are only necessary if the are multiple commands on the line separated with ';'.
# 16  
Old 03-24-2011
also I know the cron runs up to the execution of the

Code:
./hash.pl robtest > $newfiles

It is at this point it fails to run in cron. However from acommand line it runs without issue

---------- Post updated at 10:06 AM ---------- Previous update was at 10:04 AM ----------

i put the 2nd #! in for the reference to ./hash.pl robtest > $newfiles. Its all in 1 script!!!

apologies but Im still unclear as how to implelment these debug messages!

Last edited by Franklin52; 03-25-2011 at 04:00 AM.. Reason: Please use code tags
# 17  
Old 03-24-2011
So, cron started the outer script OK, and is out of the picture.

In cron, you have not tty or environment. The closest interactive analog to cron is to run it under "rsh/rexec/remsh/ssh/ssh2 localhost <command>". You can even truss/tusc/strace in this mode: "rsh/rexec/remsh/ssh/ssh2 localhost truss -faelo /tmp/truss.tr <command>". You might need some environment (to test and to fix the problem). I have my ~/.profile set to support non-tty calls, by putting all the tty bits in one place, inside an "if [ `tty 2>&1` != 'not a tty' ] ; then". Then your <command> becomes ". $HOME/.profile;<command>" unless you do this inside "<command>".

Put logging in to ensure you get to that line, and test if you get past.

Anywhere you want to detect passing through, put:
Code:
date "+%Y-%m-%d %H:%M:%S ($$) $0 Line $LINENO" >>/tmp/croncheck.log

This User Gave Thanks to DGPickett For This Post:
# 18  
Old 03-24-2011
Many thanks DGPickett but unfortunately you're pitching in above my head and Im kinda lost!

...That siad I will try and make sense of you last post!!!

just so you are clear

* this script runs fine from command line
* from cron it runs but doesnt get past the ./hash.pl robtest > $newfiles line

Last edited by rob171171; 03-24-2011 at 12:24 PM..
# 19  
Old 03-24-2011
Quote:
#!/usr/bin/sh

cd /home/it/capopt/APNRD/S30
files=`gdate -d today +%-d_%-m_%Y`
newfiles=`gdate -d today +%-d%m`
cat *"$files"* > robtest
sleep 20
#!/usr/bin/perl -w
cd /home/it/capopt/APNRD/S30
./hash.pl robtest > $newfiles
#kill $
exit 0
To emphasise what others have noticed, you cannot have two shebang lines in the same script. Only the shebang line on the very first line will be have any effect. The second shebang line is just a comment line but I don't think it matters.
Code:
./hash.pl robtest > $newfiles

This line is very dodgy for many reasons but to correct it we need to know what is in hash.pl and the full path to hash.pl .
# 20  
Old 03-24-2011
see contents of hash.pl

Code:
#!/usr/bin/perl

##############################################################

#use strict;
use warnings;

my $hash = ();

sub trim($)
{
        my $string = shift;
        $string =~ s/^\s+//;
        $string =~ s/\s+$//;
        return $string;
}


#$target_filename = shift;
#open(SESAME,"<$target_filename") || die "Cannot open file for output\n";

while(<>){
        @fields = split(/\|/, $_);
        $msisdn = trim($fields[2]);
        $APNREQ = trim($fields[4]); if ($APNREQ eq "") { $APNREQ = "NULL"; }
        $APNSUB = trim($fields[5]);
        if($msisdn =~ /^353/){

        $msisdn .= "-$APNREQ";
        $msisdn .= "-$APNSUB";
        if (exists $hash{$msisdn}) {
        $num = $hash{$msisdn};
        $num++;
        delete $hash{$msisdn};
        $hash{ $msisdn } = $num;
        } else {

        $hash{ $msisdn } = '1';

        }

    }

}

while ( my ($key, $value) = each(%hash) ) {

@apns = split(/\-/, $key);

#print "$value " ."|" . "$apns[0]" . "|" . "$apns[1]" . "|" . "$apns[2]\n";
print "$value " ."|" ."$apns[0]" . "|" . "$apns[1]\n";

}


Last edited by Franklin52; 03-25-2011 at 04:01 AM.. Reason: Please use code tags
# 21  
Old 03-24-2011
Probably a lack of environment, as no #!/usr/bin/perl -w as the first line of ./hash.pl would fail interactively, and most commands do not care there is no tty. For instance, ps -f is tied to your tty, ps -fp $pid is not, nor ps -fe | grep -c <pattern>, ps -fu <user_id>!

Put a "set >/tmp/mycronenv" into the script, let cron run it, and compare it to "set >/tmp/mytermenv" using diff.
This User Gave Thanks to DGPickett For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Python Thread Execution Issue . . .

Greetings! I set up a basic threading specimen which does the job:#!/usr/bin/python import threading class a(threading.Thread): def __init__(self): threading.Thread.__init__(self) def run(self): print("thread a finished") class b(threading.Thread): ... (0 Replies)
Discussion started by: LinQ
0 Replies

2. Solaris

How to measure IOPS?

Hi I have a system running solaris 10, and I intend to use a NetApp as its storage system. The application requires a throughput between the server and the storage 7000 disk IOPS (random IO sustained throughput with response time of 20 mili second and 16k block size). How to make sure that I... (6 Replies)
Discussion started by: fretagi
6 Replies

3. AIX

How to measure waiting time in run queue?

Hello guys, I am doing a performance analysis on one of our psystem. Most of time I am using Nmon analyser to do my trend graph. But I can't find any help with it. We are interesting in the time spend by tasks in Aix run queue. After looking the Aix documentation, I am pessimist to find any... (3 Replies)
Discussion started by: GiiGii
3 Replies

4. UNIX for Advanced & Expert Users

Implementing thread in UNIX

Hi For our load testing , we are using stubs (unix shell script) which send the response to the request coming from the application. As the unix stub is single threaded , it is responding to only one request whereas multiple requests come in parallely. I haven't worked on thread concepts... (5 Replies)
Discussion started by: jenanee
5 Replies

5. Solaris

What exactly does 'zpool iostat' measure?

hi there, i'd like to know what exactly zpool's iostat (-v) output measure, especially the writes. Is it only the writes to the ZIL or all writes (including commmits) to the disks? if anyone knows, that'd be helpful roti (1 Reply)
Discussion started by: rotunda
1 Replies

6. UNIX for Advanced & Expert Users

How to measure g++ performance?

I am working on an application with some rather interesting build performance issues. If we build on Solaris/Linux x86/AMD64 the build is rather fast, but it takes more than five times as long on our Solaris Sparc servers (single-threaded builds on the workstations, but multi-threaded on the... (5 Replies)
Discussion started by: Elric of Grans
5 Replies

7. Shell Programming and Scripting

Is there a command to measure compile speed?

Hello Ive written 2 programs in shell and I need to compare their speed (Compile) against one another. what methods could I go about doing this? Is there a feature in shell do accommodate this? (2 Replies)
Discussion started by: Darklight
2 Replies

8. Forum Support Area for Unregistered Users & Account Problems

How to post a new thread (Regarding Unix related doubts) in Unix Forums

How to post a new thread (Regarding Unix related doubts) in Unix Forums. I registered my id but I am unable to post my Questions to Forum. Thanks & Regards, indusri (1 Reply)
Discussion started by: indusri
1 Replies

9. UNIX for Dummies Questions & Answers

CPU load unit of measure?

If unix says my cpu load is 2.15 exactly what does that mean? --Jason (1 Reply)
Discussion started by: Mac J
1 Replies
Login or Register to Ask a Question