LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-14-2012, 05:46 AM   #1
abhi7514
LQ Newbie
 
Registered: Sep 2012
Posts: 5

Rep: Reputation: Disabled
Question Delete Unix/Linux file at a specific time in future.


Hi,
I was wondering if there is a command to delete a file in the future.

For example: If I create a file named unix.lst using the vi editor, but after I create it, what command will be suitable to delete "unix" files from the system at 13:40 military time with no log file.

I was going to use : find /root -name unix -exec rm {} \;
but I believe that it wont really work the way I want it to.
It would be extra helpful if you could give an command example using my original unix example.
I would really appreciate your take on this.
Thanks in advance
 
Old 09-14-2012, 05:55 AM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,241

Rep: Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325
If you know the dir of the unix.lst file eg /data, then
Code:
rm /data/unix.lst
and use either the at cmd http://linux.die.net/man/1/at for a one-off occurrence, or use cron http://www.adminschoice.com/crontab-quick-reference for repeated occurrences.

If you don't know the location(?), then
Code:
find / -name unix.lst -exec rm {} \;
and use at or cron as above.
 
Old 09-14-2012, 09:11 AM   #3
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora
Posts: 2,630

Rep: Reputation: 495Reputation: 495Reputation: 495Reputation: 495Reputation: 495
i suppose you could use cron to remove it, but it will leave a log.
 
Old 09-14-2012, 09:37 AM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,331
Blog Entries: 55

Rep: Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530
Quote:
Originally Posted by abhi7514 View Post
at 13:40
You could use 'sleep':
Code:
sleep $[$(/bin/date --date="14:30" +%s)-$(/bin/date +%s)]s && doSomething

Quote:
Originally Posted by abhi7514 View Post
with no log file.
Could you explain why you would want to delete a file in the /root directory without leaving a trace?
 
2 members found this post helpful.
Old 09-15-2012, 09:41 PM   #5
abhi7514
LQ Newbie
 
Registered: Sep 2012
Posts: 5

Original Poster
Rep: Reputation: Disabled
Thanks for your responses.
The root was just an example similar to the one in the book I was reading for practice.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
unix shell script:How to delete the first line in a file?? rche3252 Programming 6 03-03-2010 08:32 AM
Find folders with ONLY one specific file in and delete file and folder - How ? gedi1 Linux - Newbie 5 10-21-2009 09:09 PM
Delete specific lines of a file beginning with a certain letter docaia Programming 4 08-25-2008 12:04 AM
Keep specific file types, delete the rest ? jchambers Programming 5 11-26-2007 07:25 PM
Warning: File 'sendmail.cf' has modification time in the future G-Rad Linux - Newbie 0 03-07-2004 12:09 AM


All times are GMT -5. The time now is 08:20 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration