When were all scripts on the Solaris server last executed?

Hi All,

I am new to this forum and I am hoping someone will be able to help me:)

I have inherited a very old Solaris server that has a number of scripts around 500 in total.

I need to migrate the scripts to Linux but I would like to know which ones are currently being executed rather than migrating all 500 of them.

Is there a way in Solaris 5.9 to do this? I have googled and I believe there is a way in the later versions but not sure about this ancient version.

Any help would be greatly appreciated:)

It's always a good idea to search the forums before asking a question (which is also the forum rules).

See this prior thread and it should give you the clues you need:

Hi Neo,

I read that post but I do not believe I can use accounting -see in the version of Solaris I have can I.

I tried the two ls commands but they don't give me what I need.

I need a list of all scripts executed on the Solaris box over the previous month or to turn something on that can monitor for the next month to see what is being run currently so I can work out what scripts to move to the Linux box.

Cheers

Sorry, I don't run Solaris 5.9 so I have no machine to help!

We do have the man pages available for 5.10 maybe you can find a reference there:

Thanks Neo,

I'll take a look and see if I can find anything:)

Cheers

If you look at this man page:

You can see the ls option:

 -u	Uses time of last access instead of last modification for sorting (with the -t	option)  or  printing (with the -l option).

Seem like that kind of command, ls -u combined with find or a similar method will be helpful and meet your objective.

You're asking how to know which scripts run during the next month. So are users still using this system? If so, can't you ask them what commands they are running? If cron is automatically running stuff, why not pull up the crontabs and look at them?

Files are normally in:

/usr/spool/cron/crontabs

one file per username that has jobs scheduled. Although you shouldn't edit these files directly, they are perfectly readable with 'cat' for example.

Sorry if I'm on the wrong track here but I'm not clearly understanding your difficulty.

Please elaborate on the problem.

Solaris 9 is old (released in 2002, supported until 2014), but is not ancient. The "ls" command hasn't substantially changed in the last 3 or 4 four decades so identifying the scripts that have been accessed is a first and easy step. Same for accounting which was supported by Solaris 9.

Anyway, a simple method to identify if existing scripts are executed is to wrap them with a logger script.

For example, assuming you have several shell scripts in the /opt/local/bin directory

You create a directory /opt/local/bin_org and move the scripts you want to monitor in it, then you create a wrapper script and have the system using it when the original scripts are expected:

cd /opt/local/bin/
cat > .wrapper <<%
#!/bin/ksh
echo \$0 "\$@" called at \$(PATH=$(getconf PATH) date +%Y%m%dT%H%M%S) >> /var/tmp/scriptLogs
exec \$(PATH=$(getconf PATH) dirname \$0)/../bin_org/\$(PATH=$(getconf PATH) basename \$0) "\$@"
%
chmod +x .wrapper
for script in ../bin_org/*; do
    ln .wrapper $(basename $script)
done

Execution logs will be in /var/tmp/scriptLogs

2 Likes

Sorry for the delay in responding and thanks for all your responses.

So basically I am in the process of migrating from Solaris 5.9 to Linux.

We are in the build stage and the Linux system is currently run by another vendor who cannot/ will not confirm what scripts are currently running.

There are over 500 shell scripts on the old Solaris server and I have no idea which ones I need to migrate to Linux.

Hence the question about how do I know what is currently being executed.

I am in the process of wading through the crontabs but was looking for a more time effective method of identifying currently used scripts.

Cheers

Why not just copy over all the files (scripts) and be done with it for now?

That way you will not have many mistakes.

Alternatively, you might just move to a supported Solaris Version (11.4), or to an OpenSolaris now Illumos derivative...