Creating conditional symlink

Login or Register for Dates, Times and to Reply

Thread Tools Search this Thread
Operating Systems Linux Ubuntu Creating conditional symlink
# 1  
Creating conditional symlink

Hi All,
Is there any way to create a symlink that will point to last 1000 line of a log file. My symlink will always point to "tail -1000 logfile".

This can be achieved by writing a script and scheduling with high frequency, but I am looking for some other alternatives.

Please let me know if there is any way to do so.

Thanks in advance.
# 2  
A symlink has to point to a physical file if you want it to return a file descriptor on open.
So, what you are asking is interesting but does not make sense to me.

Rather than you telling us how to do it, please tell us what you are trying to accomplish.

Do you know about
tail -f

This User Gave Thanks to jim mcnamara For This Post:
# 3  
I am looking for a way to create a symlink which will point to last 1000 lines of a logfile. The link will dynamically point to the last 1000 lines always.

My log file is huge and I am only interested to see what happened recently.
# 4  
Use an alias.
This User Gave Thanks to RudiC For This Post:
# 5  

Alias will help to get the last 1000 lines dynamically. I am planning to expose this file using web server for external users to read. In this case will alias be helpful?

If there is any other approach please suggest.
# 6  
May a named pipe?

Create a named pipe:
mkfifo /tmp/watch_log

Point the tail command to it and background it:
tail -f -n1000 logfile > /tmp/watch_log &

Watch it using the cat command:
cat /tmp/watch_log

This User Gave Thanks to in2nix4life For This Post:
# 7  
A symlink points to a file. It can't do anything else.
Login or Register for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #711
Difficulty: Easy
The earliest computing machines had fixed programs.
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers


I know how to create a symlink but I am getting an error message that the file already exists. Also, my symlink doesn't point from target directory to the path correctly, Here is an example of the path to my folder structure path: cd /wkspce/wff/DEV/jobs/DEL the folder structure is: ... (3 Replies)
Discussion started by: dellanicholson
3 Replies

2. Shell Programming and Scripting

Symlink creation

I am trying to setup my plex server to use symlinks rather than host the movie files. in my storage directory, i have both movies(some in subdirectory of the name and some just in the parent directory) and tvshows, which have subdirectories for each season, which contains the episodes i would... (3 Replies)
Discussion started by: bandion
3 Replies

3. UNIX for Dummies Questions & Answers

Remove symlink and target

i would like to remove a directory and also symlink target inside. my_directory -- file1 -> /targetpath/file1 -- file2 -> /targetpath/file2 rm -rf my_directory will not remove symlink target. rm -rf "`readlink -f file1`" will only remove target if specifying the symlink is specified ... (4 Replies)
Discussion started by: lsy
4 Replies

4. Red Hat

how to hide the path users on the symlink.

Hello, can someone please suggest or is it possible to hide the path for the link from viewing it from remote users. for examples. as root user login #ls -l lrwxrwxrwx 1 root root 43 Oct 2 16:05 sftpdata -> /data/sftphome/sftpuser1/sftpdata/ #pwd /home/user1 # when user1 logs... (4 Replies)
Discussion started by: bobby320
4 Replies

5. UNIX for Dummies Questions & Answers

Advanced Symlink Creation script

Hello. I am working on creating a script to recursively run on my media collection. The goal is to recreate the folder structure, but with slight changes in the folder names based on my rules. The folders will also include the .jpg & .mkv files, renamed according to a similar set of rules. ... (4 Replies)
Discussion started by: Davinator
4 Replies

6. Shell Programming and Scripting

ln -s creates symlink in symlink, if [ -f ... ] says file that exists doesn't exist

Hi Forums, I got a little problem, I made a few modifications to the code of the launch script of a testing server(minecraft) and now updating is broken aswell as the automatic directory creation. These Lines somehow create an endless symlink that refers to itself and I don't know how to fix... (0 Replies)
Discussion started by: Xaymar
0 Replies

7. Solaris

symlink on link file

Hi all, I want to create a symlink on a link file, i mean, there is a file which is actually a symlink of some version. Now i want to create one more symlink on that link file. EX: there is a file: uat -> version prod -> version Now i want to create one more link on these 'uat' and... (1 Reply)
Discussion started by: raghu.iv85
1 Replies

8. UNIX for Dummies Questions & Answers

creating symlink

hi... I have a folder<abc> under /root folder. I want to create a symlink such that when i click on folder<abc> under root, should display my home folder (home/krish). Immediate inputs appreciated..... (1 Reply)
Discussion started by: rama.honge
1 Replies

9. UNIX for Dummies Questions & Answers

creating conditional logs

Hi all, I am new to scripting and hope to get help in this forum...we use autosys ... the jil files call shell scripts (korn shell) for automated processes and create logs everytime they are run...the process runs every 5 mins which is creating huge logs...i need to know if logs be created... (0 Replies)
Discussion started by: sonali007
0 Replies

10. Shell Programming and Scripting

creating a script using the case conditional

hello, i am a newbie who is just starting to use liunx, and I need to accept a string from the terminal and use case to echo a suitable message if the string doesn’t have at least 10 characters. Also, how would I do the same thing using expr? (3 Replies)
Discussion started by: soccerstr1
3 Replies

Featured Tech Videos