?
Solved

Delete script that runs in the background

Posted on 2005-03-10
6
Medium Priority
?
225 Views
Last Modified: 2010-04-21
I'm planning to write a delete script, and i found some good stuff @ EE
This script to be exactly:

find /data -ctime +30 -exec rm {} \;

this will delete all files that are older then 30 days in the folder      /data     right ?

If the above is correct i want to add one more thing. I don't want to execute the script myself once in a while but i want the script to keep running in the back ground, and check every 2 days (or every day) for files that are older then 30 days in the folder /folder.

Is this possible ?

thnx in advance


Sark
0
Comment
Question by:Mr-sark
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 45

Accepted Solution

by:
sunnycoder earned 500 total points
ID: 13503872
Hi Mr-sark,

This is very much possible .... set it up as a cron job

man 5 crontab

An example from the man page
================================================
       # run five minutes after midnight, every day
       5 0 * * *       $HOME/bin/daily.job >> $HOME/tmp/out 2>&1



Cheers!
sunnycoder
0
 
LVL 1

Author Comment

by:Mr-sark
ID: 13503912
i'm new to this so could you maybe explain this line to me


5 0 * * *       $HOME/bin/daily.job >> $HOME/tmp/out 2>&1

and where do i put this file ?
0
 
LVL 1

Author Comment

by:Mr-sark
ID: 13503953
back again, quess i found out how it works, so correct me if i'm wrong

if i take a look at /etc/crontab i'll see these lines:

[code]
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/

# run-parts
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly
[/code]

so i'll put the script

[code]
find /data -ctime +30 -exec rm {} \;
[/code]

in the file /etc/cron.daily

to let this file execute every dat ? righ ?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 45

Expert Comment

by:sunnycoder
ID: 13503954
Hi Mr-sark,

>>man 5 crontab

/etc/crontab

Cheers!
sunnycoder
0
 
LVL 45

Expert Comment

by:sunnycoder
ID: 13503963
You can do that too ... You can put your commands in a file and put that script in cron.daily
0
 
LVL 45

Expert Comment

by:sunnycoder
ID: 13503971
Hi Mr-sark,

> in the file /etc/cron.daily
Its a directory :-) ... read the man page, it will help .. I cannot explain better than those guys

Cheers!
sunnycoder
0

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question