LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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, 04: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, 04:55 AM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
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, 08:11 AM   #3
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora/Pop!_OS
Posts: 2,983

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

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
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, 08: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



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 07:32 AM
Find folders with ONLY one specific file in and delete file and folder - How ? gedi1 Linux - Newbie 5 10-21-2009 08:09 PM
Delete specific lines of a file beginning with a certain letter docaia Programming 4 08-24-2008 11:04 PM
Keep specific file types, delete the rest ? jchambers Programming 5 11-26-2007 06:25 PM
Warning: File 'sendmail.cf' has modification time in the future G-Rad Linux - Newbie 0 03-06-2004 11:09 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:56 PM.

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
Open Source Consulting | Domain Registration