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.
Environment (exported variables) is #1. When you log in, all sorts of scripts run before your shell prompt arrives, setting your environment so the shell is useful. The cron and rsh/ssh waste no time on this, so you have to explicitly add the missing environment.
Lack of a tty is usually less of a problem, so it is #2.
Some programs get upset when the default stdin cannot be read or gets EOF immediately. Since there is no tty, there is no keyboard, there can be no input but that supplied in the scripting.
Both ld_library_path and path are critical to everything, and if you want Oracle, you have to get those, too. You can 'source' your .profile or make a special env file for cron to source. If .profile works but complains in an ugly way, just redirect it away (. $HOME/.profile >/dev/null 2>&1).
Don't forget to export EACH_VAR_NAME, which can be the same line if not sh (export THIS_VAR_NAME=THIS_VAR_VALUE) ! You really want to move to ksh or bash, sh is pretty retro!
Sorry but you're problem has no link with first problem (measuring thread execution) and I will never have answer if this topic speaks about another problem.
Could moderator splits this message to have separate discussions please ?
One dir is a symbolic link to the other, except in later Solaris, where one dir supports boot and the other supports more complex apps, so you have to do both / and /usr in PATH, LD_LIBRARY_PATH.
Without LD_LIBRARY_PATH, dynamically linked programs cannot find their libs.