Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 281
  • Last Modified:

blank text file

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
XK8ER
Asked:
XK8ER
  • 2
1 Solution
 
woolmilkporcCommented:
0 * * * * /usr/bin/touch /path/to/file.txt
0
 
XK8ERAuthor Commented:
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
 
woolmilkporcCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now