Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

blank text file

Posted on 2011-09-14
3
248 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
ID: 36537853
0 * * * * /usr/bin/touch /path/to/file.txt
0
 
LVL 1

Author Comment

by:XK8ER
ID: 36537871
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
ID: 36537938
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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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). …
Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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.

856 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