script to remove and recreate a lock file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting script to remove and recreate a lock file
Prev   Next
# 1  
Old 04-05-2012
script to remove and recreate a lock file

Hi all,
i have a small script to remove locks for the prevous day and create new lock for processing in the path on my server
i have made something like this
Code:
#!/bin/sh
#lock_remover
#script to remove regular lockfiles and hang
curr_month=`date "+%b"`
2day=`date "+%_d"`
cd /rbs/batchProcs/locks
curr_status=`ls -ltr`
for i in $curr_status
do
if [$6 !=$curr_month && $7!=$2day] then
locked_file=$9
rm -f $locked_file
touch $locked_file
fi
done
exit

it returning this error
lock_remover: line 6: 2day=: command not found
lock_remover: line 15: syntax error near unexpected token `fi'
lock_remover: line 15: `fi'

thanks
Moderator's Comments:
Mod Comment please use code tags

Last edited by jim mcnamara; 04-05-2012 at 07:38 AM.. Reason: code tags
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. HP-UX

Ignite-UX INDEX file messed up, how to recreate?

OK, so I just messed myself up. Thinking the /var/opt/ignite/data/INDEX files was static, I manually edited the file and added 2 more OS's to it. During an Install it only showed the first OS (started with 11.31, 3 versions then added a 11.23, and a 11.11 stanza's). The 11.23 and 11.11 never... (2 Replies)
Discussion started by: mrmurdock
2 Replies

2. Shell Programming and Scripting

Script calling multiple scripts (using lock file)

Hi all, i have compiled a script as below. Basically this script is intended to call 3 other scripts, which i intend to run simultaneously. #!/usr/bin/bash HOMEDIR=/path/of/home LOCKDIR=$HOMEDIR/lock #check for LOCK LOCKFILE=$LOCKDIR/$(basename $0 .sh).lock if ; then echo... (2 Replies)
Discussion started by: nms
2 Replies

3. Ubuntu

How to lock a file through UNIX KSH shell script?

I wrote two shell scripts in UNIX that renames the same file and scheduled them at the same time. The following are the steps that I followed:- 1. I wrote 2 scripts named s1.sh and s2.sh, both trying to add “exec_” prefix to the name of the files present in a folder i which already don't start... (4 Replies)
Discussion started by: piuli
4 Replies

4. Shell Programming and Scripting

No lock file: Preventing multiple instance of a script

I've been bitten by using a lock or pid file to prevent multiple instances of a script. A user typed kill -9, and the pid file didn't go away. You can't trap -9. So when he tried to restart, it said "already running", and I got trouble report. Argh. So here's what we came up with: # Stop if... (1 Reply)
Discussion started by: McFadden586
1 Replies

5. UNIX for Advanced & Expert Users

Testing privileges -lock lockfile /var/lock/subsys/..- Permission denied

Hi all, I have to test some user priviliges. The goal is to be sure that an unauthorized user can't restart some modules (ssh, mysql etc...). I'm trying to automate it with a shell script but in same cases I got the syslog broadcast message. Is there any way to simply get a return code... (3 Replies)
Discussion started by: Dedalus
3 Replies

6. Shell Programming and Scripting

Delete and Recreate around 400 Symbolic Links in one Folder

Hello, I recently just switched my phphandler to suPHP on my server in order to increase security a bit. I am working with 2 scripts, one of which is vbulletin forums and the other is custom. The vbulletin forum avatars are all symbolic links to pictures in the other custom script. When I... (2 Replies)
Discussion started by: ambition13
2 Replies

7. Red Hat

Security Question: Lock after invalid login, Session Lock and Required Minimum Password Length

Hello all, If anyone has time, I have a few questions: How do I do the following in Linux. We are using Red Hat and Oracle Enterprise Linux, which is based on Red Hat too. 1. How to lock the account after a few (like 3) invalid password attempts? 2. How do you lock a screen after 30... (1 Reply)
Discussion started by: nstarz
1 Replies

8. OS X (Apple)

Please look at this screen shot: How do I remove this lock icon?!

RESOLVED in the screen shot I'd like to remove the lock sandwiched between the spaces indicator and the monitor icon, how do I get rid of it? It locks the screen and I cannot remember how it came to be http://guptaxpn.com/tmp/lock_icon_screenshot.png Thanks for your help! (3 Replies)
Discussion started by: guptaxpn
3 Replies

9. Solaris

how to recreate scripts under /etc/rc3.d folder

Hi All, We have the JMS Queue startup script S52imq and some other scripts in our solaris server 5.8 version. now unknowingly something happend to those scripts and its lost. How can I recreate those scripts again to start the JMQ queue again? We have Solaris 5.10 version which is having... (3 Replies)
Discussion started by: nsurendiran
3 Replies

10. UNIX for Advanced & Expert Users

How to remove CVS lock

Hi All, CVS repository is setup on linux server and we are using wincvs to checkout/tag .. etc but we are getting below lock error so how to remove this lock and what is the reason for lock?? cvs rtag: waiting for username's lock in /space/cvs/modulename (1 Reply)
Discussion started by: bache_gowda
1 Replies
Login or Register to Ask a Question