- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- symbolic link script
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2002 02:52 PM
07-30-2002 02:52 PM
symbolic link script
This is on an hp-ux 11.11 system.
Thank you,
Carol
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2002 02:54 PM
07-30-2002 02:54 PM
Re: symbolic link script
Would a simple find command do it?
find /path -type l -mtime +1 -exec touch {} \;
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2002 01:27 PM
07-31-2002 01:27 PM
Re: symbolic link script
The touch command doesn't work on sym links and the -mtime +1 would find files more than 1 day old, but not 1 day in the future.
But thanks so much for your input. I do appreciate it.
Carol
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2002 01:52 PM
07-31-2002 01:52 PM
Re: symbolic link script
How about this perl script-
open(INP,"find /path -type l -print|");
$now=time();
while(
@a=lstat($_);
next if $a[8] > $now;
$real=readlink($_);
unlink $_;
symlink($real,$_);
print "Updated $_ to $real\n";
}
close(INP);
This will look at symbolic link files, look at the last access time of the link file itself and compare to the current date.
Since you can't touch a link, just remove it and recreate it.
Hope this helps...
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2002 01:56 PM
07-31-2002 01:56 PM
Re: symbolic link script
I don't have a script, but suggest that it could be done fairly easily using perl.
Chris
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2002 12:50 AM
08-01-2002 12:50 AM
Re: symbolic link script
why not use Perl's File::Find module? (meanwhile it is part of the standard suite of modules).
Even if you're unsure how to write the callback function yourself, Perl can help you with its find2perl converter.
At the shell just try something like:
e.g.
find2perl /etc -type l > my_link_renewer.pl
To place further tests of mtimes and your unlink(), and symlink() calls in there should be straight forward.
Btw. always test opens for success, because with the pipe appended Perl is forking off a child, and connecting STDIN and STDOUT handles for the parent to read and the child to write.
Apart from this she was asking for the mtime not the atime.
When I have a look at the POD of stat() it should be in the 9th returned list element,
so something like
next unless ($now > (lstat $_)[9] && -l _);
looks more appropriate to me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2002 11:28 AM
08-12-2002 11:28 AM
Re: symbolic link script
I would like to thank you for your help. The action I actually took to solve my symbolic link date problem was to use a script from Eric Herberholz from HP Tech Support below. It worked! Thanks so much for all your responses...I appreciate it!
Carol
#!/usr/bin/sh
# unsupported script
find / -type l -exec ls -ld {} \; | awk '{
printf("rm %s;ln -s %s %s\n",$(NF-2),$(NF),$(NF-2));
}' >/tmp/doit
-------------------------
Notice the "unsupported script" comment above. This script assumes that there aren't any spaces in the name of the symbolic link nor in the name of the actual file.
Look at the results in /tmp/doit and then decide if it has acurately captured the commands need to remove the symbolic links and recreate them. And then if it does, you could run /tmp/doit by making it executable or by running 'sh /tmp/doit'.