Portal Home > Knowledgebase > Articles Database > /tmp cron jobs
/tmp cron jobs
Posted by vimansani, 11-17-2013, 11:53 PM |
My /tmp directory is getting full in every 3 weeks. After that I'm giving fallowing command to delete temp files.
I just want to know is there have a automated system to run this command. I want to run this command in every week.
Can I use cron jobs? If possible please let me know how to do that.
|
Posted by net, 11-17-2013, 11:54 PM |
Moved > Hosting Security and Technology.
|
Posted by HostingBig, 11-18-2013, 12:00 AM |
create a file in your desired location
/directory/cleantmp
add the fowling in your file chmod the file to 755 and add it to your cron to run once a week
or just install tmpwatch
|
Posted by vimansani, 11-18-2013, 12:04 AM |
Please tell me how to add that to cron? I'm new to Linux. Can you ggive me the full command for cron ?
|
Posted by luki, 11-18-2013, 12:10 AM |
As root, run crontab -e to edit the cron tab. Add a new line at the end like this:
0 */12 * * * find /tmp -cmin +720 -exec rm {} \;
Save and exist the crontab editor. The above command will run every 12 hours.
|
Posted by HostingBig, 11-18-2013, 12:18 AM |
or just install tmpwatch
yum install tmpwatch
if you are using redhat variant
|
Posted by ALEXEI_M, 11-18-2013, 01:37 AM |
Hi
root@server1 [/]# 0 */12 * * * find /tmp -cmin +720 -exec rm {} \;
-bash: 0: command not found
|
Posted by ALEXEI_M, 11-18-2013, 01:37 AM |
I also have the same issue. This is not working.
|
Posted by vimansani, 11-18-2013, 01:41 AM |
tmpwatchis is already installed. I will check with the cron
|
Posted by Kailash12, 11-18-2013, 01:48 AM |
You missed one command. First you need to edit your crontab using the following command:
crontab -e
And then add the command at the end of file and save it.
|
Posted by vimansani, 11-18-2013, 01:54 AM |
Thanks , Now its works.
@Alexe Log in to your root and type " crontab -e "
After that past # 0 */12 * * * find /tmp -cmin +720 -exec rm {} \;
|
Posted by ALEXEI_M, 11-18-2013, 01:55 AM |
There is no place to edit
My os is Fedora
|
Posted by NoSupportLinuxHostin, 11-18-2013, 02:01 AM |
I would also suggest tmpwatch. You could run the following line to clear everything older than 6 hours from the /tmp folder.
/usr/sbin/tmpwatch -am 6 /tmp
You can cron that command and run it hourly if you want.
If tmpwatch is not already installed, run this line:
yum install tmpwatch
|
Posted by AttackerNET, 11-18-2013, 10:29 PM |
Please try running this as root:
Then restart crond by running:
|
Add to Favourites Print this Article
Also Read