Solved

blank text file

Posted on 2011-09-14
3
260 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
[X]
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
  • 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

751 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