Some help with a find/fuser/gzip crontab job

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Some help with a find/fuser/gzip crontab job
# 1  
Old 09-16-2013
Some help with a find/fuser/gzip crontab job


I am trying to write a housekeeping that finds all .trc files older than x days in a given FS, checks if they are used and gzips them if they are not used by any process. I need to do it without calling any additional .sh script.

I managed to make it work for Linux only:

find . -xdev -name "*.trc" -type f -mtime +5  -and -not -exec fuser -s {} ';' -and -exec gzip -9f {} ';'

Please advise how can I make it work on UNIX too. The '-and -not' options are not available there.

Any help would be highly appreciated.

Last edited by joeyg; 09-16-2013 at 10:14 AM.. Reason: Please wrap commands and data within CodeTags
# 2  
Old 09-16-2013
There are many UNIXes... depending what you mean with "UNIX", they are usually there. If you would check the man page for find, you might find -a and -o instead.
# 3  
Old 09-16-2013
Sorry, I forgot to mention it's HP UX
# 4  
Old 09-16-2013
Ok, did you check the man page for the switches I mentioned? Did it help?
# 5  
Old 09-17-2013
I tried it with -a -o but it gzipped everything, not only .trc files:

find . -xdev -name "*.trm" -type f -mtime +5 -a -exec !fuser -s {} ';' -o -exec gzip -9f {} ';'

I am doing something wrong but I am not sure where in the syntax
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Manipulate files with find and fuser not working as expected on SunOs

Greetings, For housekeeping, I use the following command: find /some/path -type f -name "*log*" ! -exec fuser -s "{}" 2>/dev/null \; -exec ls -lh {} \; It finds all log files not currently in use by a process and manipulates them. This command always works on linux and redhat machines,... (2 Replies)
Discussion started by: dampio
2 Replies

2. UNIX for Dummies Questions & Answers

Crontab job is not working

hell all: i am trying to test a crontab job for snmpwalk but it is not working: here is crontab: */1 * * * * root /root/ for the script, it is very simple: #!/usr/local/bin/bash /usr/local/bin/snmpwalk -v 2c -c public (6 Replies)
Discussion started by: ipfreak
6 Replies

3. UNIX for Advanced & Expert Users

Fuser alternative OR running fuser on a script

Hi, Not sure whether there is a fuser alternative or any better way to check for file in use or not. I am wanting to check whether files are in use or not before removing them. Using fuser, the awk seems to be giving me 'weird' output not to mention that it is giving me 2 lines instead of... (0 Replies)
Discussion started by: newbie_01
0 Replies

4. SuSE

A crontab job not working

Hello, This is my first posting in Linux world. I have SLES 11. I've created a file 'packdisk-scandisk.txt' file under /var/opt/Teradata/bteqdba. The content of the file is, cat /var/opt/Teradata/bteqdba/packdisk-scandisk.txt output over /var/opt/Teradata/bteqdba/TAREAS_DBA.log... (2 Replies)
Discussion started by: JDBA
2 Replies

5. HP-UX

Cron Job tar gzip

Hello, why does this script only creates a 1 kb file? executing the same line directly on the shell works well. #!/bin/sh tar c /rente/DATEIEN /rente/FORMS |gzip > /rente2/RD-Date.tar Greets Use code tags please, see PM. (2 Replies)
Discussion started by: penne
2 Replies

6. Shell Programming and Scripting

Schedule a job using Crontab

I would like to execute my script at 17.30 and 23.00 using crontab, could anybody help me out!! Thanks in Advance!! (1 Reply)
Discussion started by: jatanig
1 Replies

7. UNIX for Dummies Questions & Answers

crontab job not running

Hi all, down here part of the scheduled job in crontab (AIX Version 5) i have problem running jspPRE-ALL. i verrify permissions and privileges (the others job are working good) if i run the job in command line it work correctly # # Aggiornamento doni e continuity 00 02 * * 2-6... (5 Replies)
Discussion started by: ilpasta
5 Replies

8. Shell Programming and Scripting

Help with a crontab job!!!

Hi, i need to schedule a script to run at 6.10AM everyday.I tried to do this way. #!bin/ksh 10 06 * * 0-6 sh /tmp/ss/script/ And at the command prompt I did >crontab -e cron.txt I'm not sure whether this is the right way. Can anyone please tell me how to... (4 Replies)
Discussion started by: kumarsaravana_s
4 Replies

9. UNIX for Dummies Questions & Answers

Crontab job queue

My cronjob triggers the script late by 6 minutes. /var/cron/log shows that it got triggered at the right time then where can I track, the late starting of the script. Is there some queue mechanism, some log? This happens sometimes, not daily. but it affects me, whenever it happens. Logging... (1 Reply)
Discussion started by: pksingh2
1 Replies

10. UNIX for Dummies Questions & Answers

crontab job

Hi, I have cornjob was scheduled at 1:00 AM everyday. It has been running fine since last Saturday. But it didn't run since Saturday. Because of daytime saving time change it didn't ran? Please send me your thoughts. Thanks in adavance. Moe (3 Replies)
Discussion started by: Moe
3 Replies
Login or Register to Ask a Question