Operating System - Linux
1752803 Members
5553 Online
108789 Solutions
New Discussion юеВ

Re: help script .. make soft link

 
file system
Frequent Advisor

help script .. make soft link

Hi all
that you gave tips are very helpful.

can I have your tips for script.

we have a problem.

Sometimes
some links are removed abruptly.
so some web services are bad in state.


[root@web apps]# ll
total 0
lrwxrwxrwx 1 root root 14 Sep 21 13:54 portal -> /nasnew/portal
[root@web apps]# pwd
/opt/FJSVj2ee/var/deployment/ijserver/portal/apps

as you see portal has been removed..
so
I want to have some scripts to make soft link when it is removed
the script will be cron service , for every 1 minute.
Any help will be fine.
2 REPLIES 2
Alexander Chuzhoy
Honored Contributor

Re: help script .. make soft link

You wrote: "as you see portal has been removed.."
I don't think it's possible to see from your post what was removed.

Below is the solution in Perl (I don't have linux console to check the shell's solution):

#!/usr/bin/perl
$link = "path_to_some_link";
unless ( -l $link) {
symlink(OLDFILE,NEWFILE); #Creates a new filename symbolically linked to the old filename.
}
If you have several links to check - put them all in array and run the unless statement for every member of array.

Best in your situation would be to check the cause for links removal and to eliminate it.
Ilay_1
Occasional Advisor

Re: help script .. make soft link

Sobetter is to try investigate why exactly link is removed,but do following if you want only recreate link:

run
crontab -e

add folloving line

* * * * * ln -s /opt/FJSVj2ee/var/deployment/ijserver/portal/apps/portal /nasnew/portal