How to create symlink for latest file only?


Login or Register to Reply

 
Thread Tools Search this Thread
# 15  
Here it says in /var/mail/root
Code:
Your "cron" job on v911a-proxy1-prod
cd /var/log/apache && rm -f error_log && ln -s $(ls -r *error_log.* | head -1) error_log

produced the following output:

sh: syntax error at line 1: `(' unexpected

# 16  
Quote:
Originally Posted by solaris_1977
Here it says in /var/mail/root
Code:
Your "cron" job on v911a-proxy1-prod
cd /var/log/apache && rm -f error_log && ln -s $(ls -r *error_log.* | head -1) error_log

produced the following output:

sh: syntax error at line 1: `(' unexpected

I am sorry about that. I made the mistake of copying the code from post #10 that you said you were using:
Code:
13 16 * * * cd /var/log/apache && ln -s $(ls -r *error_log.* | head -1) error_log
14 16 * * * unlink /var/log/apache/error_log

which used that same construct. But, with a pure Bourne shell from the 1980s being used by cron on Solaris 10, see what happens if you try:
Code:
13 16 * * * cd /var/log/apache && rm -f error_log && ln -s `ls -r *error_log.* | head -1` error_log

Note that this assumes that your error log file names do not contain any IFS characters (usually <space>, <tab>, and <newline>). If they could contain IFS characters you'll need to add double-quotes immediately before the opening back-quote and immediately after the closing back-quote.
This User Gave Thanks to Don Cragun For This Post:
Login or Register to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Tomcat 6.0 fails to read symlink(symbolic link) file
KingaKoopa
Hello all experts, Im in a situation where Tomcat simply does not want to read this file through the symlink.... I checked permissions..OK Also checked file & tomcat owner...all OK. This is what I have my /tomcat/conf/Catalina/local/appname.xml <Context> <Resource name="jdbc/black" ...... UNIX and Linux Applications
3
UNIX and Linux Applications
create t a filelist with the latest file by YYYYMMDD and move to subfolder
kedrick
Hi all, I am receiving files named like: ABC_20120730.csv ABC_20120801.csv ABC_20120812.csv They are residing in a folder named Incoming. I am supposed to write a script that will create a filelist which will contain only the name of the latest file beginning with ABC_, by YYYYMMDD...... Shell Programming and Scripting
3
Shell Programming and Scripting
File count for symlink using find command
dixits
Hi Guys, The script which I am using works really good for finding the file count for files that are not symlink. I know I can use find command like: find . -type l | wc -l This way I can get filecount of the symlink but is there a one liner to use -type l and -type f option ? That is...... Shell Programming and Scripting
4
Shell Programming and Scripting
ln -s creates symlink in symlink, if [ -f ... ] says file that exists doesn't exist
Xaymar
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...... Shell Programming and Scripting
0
Shell Programming and Scripting
symlink on link file
raghu.iv85
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...... Solaris
1
Solaris