LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-12-2005, 11:12 AM   #1
Nanook
LQ Newbie
 
Registered: Jul 2005
Posts: 4

Rep: Reputation: 0
Question Cronjob - Newbie - Please Help!


Hello
My name is Greg, and I have looked all over for help to my problem and I hope someone here can help!!

I have a website, which is running on what I believe is a Linux server, I am not sure and have emailed my web host about this. I believe this because it uses DirectAdmin.

I want to have a feature for users to create a page based on selections which will save to a directory, for example root/users/

I would like to create a cron job that will remove all files that haven't been accessed in 7 days to save disk space that will run once a week.

The trouble is I know nothing about Cron Jobs.

Is this possible?

If it is can you please take me through it step by step, this is my first attempt at a cron file and i have no idea where to start

Screenshot of my DirectAdmin Cron Job Control Panel:
(edited with '*' to replace '.' and http removed due to 5 post URL control, this is not spam so I hope that's OK)

img340*echo*cx/img340/1049/cron3al*png

Thanks for reading this.
 
Old 07-12-2005, 03:12 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Edit crontab (crontab -e) and add this line:
* 1 * * * find /path/to/files -type f -atime +7 -exec rm {} \;


That will delete files older than 7 days every night
at 1 o'clock.
 
Old 07-13-2005, 08:19 AM   #3
Nanook
LQ Newbie
 
Registered: Jul 2005
Posts: 4

Original Poster
Rep: Reputation: 0
Thank you SOOO much, you have no idea how much you have saved me

Words can not thank you enough, rest assured I will click that thanks button!

 
Old 07-13-2005, 09:30 AM   #4
phil.d.g
Senior Member
 
Registered: Oct 2004
Posts: 1,272

Rep: Reputation: 154Reputation: 154
You should be able to fill in the details for setting the time by following those instructions, tinkster's method is only good if you have ssh access to the server, the last bit of tinkster's line; the find and onwards should be put in the command textbox on the page, read this for information on the command 'find', whilst what tinkster says will work it is good for you to understand what is happening yourself so that can edt the command to suit any change in needs further down the line
 
Old 07-13-2005, 10:02 AM   #5
Nanook
LQ Newbie
 
Registered: Jul 2005
Posts: 4

Original Poster
Rep: Reputation: 0
Thank you both

Just to clarify, and this probably sounds a bit stupid, but where do I enter that command?

Sorry for me newbishness

edit:

Ignore me, I just re-read it and figured it out

Thank you both again

 
Old 07-13-2005, 10:42 AM   #6
phil.d.g
Senior Member
 
Registered: Oct 2004
Posts: 1,272

Rep: Reputation: 154Reputation: 154
Code:
*
1
*
*
*
find /path/to/files -type f -atime +7 -exec rm {} \;
In the screenshot you gave us, put each of these lines into the separate textboxes,

you can only enter the commands like tinkster says if you have ssh access to the server, which you may or may not

and change /path/to/files to the actual location on your server.

EDIT, maybe I should read posts fully before answering

Last edited by phil.d.g; 07-13-2005 at 10:44 AM.
 
Old 07-13-2005, 10:44 AM   #7
Nanook
LQ Newbie
 
Registered: Jul 2005
Posts: 4

Original Poster
Rep: Reputation: 0
Thank you phil.d.g and tinkster
I will get on to my host soon to find out if I have SSH Access

You have both been great helps, thank you
 
  


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
cronjob help meeh Linux - General 1 03-26-2004 11:41 AM
Cronjob engnet Linux - Networking 6 03-03-2004 09:21 AM
cronjob ugob Linux - Software 0 03-03-2004 09:20 AM
Su in a cronjob michedlp Programming 3 11-06-2003 08:30 AM
cronjob FastEddy Linux - General 1 04-12-2003 09:52 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:04 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