Solved

blank text file

Posted on 2011-09-14
3
224 Views
Last Modified: 2012-05-12
hello there,
I would like to create a cron to run every hour that can erase a txt file and leave it blank..
how can I do that?
0
Comment
Question by:XK8ER
  • 2
3 Comments
 
LVL 68

Expert Comment

by:woolmilkporc
Comment Utility
0 * * * * /usr/bin/touch /path/to/file.txt
0
 
LVL 1

Author Comment

by:XK8ER
Comment Utility
touch doesnt seem to be working
[(01:35 PM)][(root@alpha)] [(~)] $ cat aa.txt
sdfsdfsd
sdfsdfsd
sdfsdfsd
sdfsdfsd
sdfsdfsd
sdfsdfsd
sdfsdfsd
[(01:35 PM)][(root@alpha)] [(~)] $ /bin/touch aa.txt
[(01:35 PM)][(root@alpha)] [(~)] $ cat aa.txt
sdfsdfsd
sdfsdfsd
sdfsdfsd
sdfsdfsd
sdfsdfsd
sdfsdfsd
sdfsdfsd
[(01:35 PM)][(root@alpha)] [(~)] $

Open in new window

0
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 500 total points
Comment Utility
Sorry, didn't read carefully enough (Smartphone!)

Try this:

0 * * * * >/path/to/file.txt

">" will erase the file or create it if it doesn't exist. It's essentially the same as

0 * * * * /usr/bin/cat /dev/null > /path/to/file.txt

wmp
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Network Interface Card (NIC) bonding, also known as link aggregation, NIC teaming and trunking, is an important concept to understand and implement in any environment where high availability is of concern. Using this feature, a server administrator …
rdate is a Linux command and the network time protocol for immediate date and time setup from another machine. The clocks are synchronized by entering rdate with the -s switch (command without switch just checks the time but does not set anything). …
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

744 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now