Membership is FREE, giving all registered users unlimited access to every Acorn Domains feature, resource, and tool! Optional membership upgrades unlock exclusive benefits like profile signatures with links, banner placements, appearances in the weekly newsletter, and much more - customized to your membership level!

cron job help

Status
Not open for further replies.

Paullas

Staff member
Joined
Jul 13, 2004
Posts
5,817
Reaction score
361
Hi

I am looking for a way to get one of my servers delete certain files at certain times of the day. Can any help me on this.
 
Sure...

What do you want to delete? File, directories?

Who owns the files?

How often do you want to run the file?

Jee
 
hi, cheers for replying.

i am wanting to delete 4 files once a day. the files are on my servers.

thanks

paul
 
WHen I say own, i meant which user owns the files? I'll assume that your user does.

Create a text file called delete.sh with this:

#!/bin/sh
/bin/rm -rf /home/user/file1.html
/bin/rm -rf /home/user/file2.html
/bin/rm -rf /home/user/file3.html
/bin/rm -rf /home/user/file4.html

Upload it to your user directory (in this case, /home/user) and chmod it 755

Then you need to create the cronjob. The easiest way is via shell:

$ crontab -e

enter this:

01 02 * * * /home/user/delete.sh

Save and exit. If you haven't got shell, or aren't comfortable using that, then your control panel should have something to help you.

The above cron line will run the delete.sh file once a day at 2:01am. I would test this out before committing it to real files, but its working fine for me!

Make sure you have backups ;)

Jee
 
:) cheers, ill give that a go.

thanks for help
 
hi

ok done that. but when i try and run it i get

: bad interpreter: No such file or directory

I am running it manual with this command ./delete.sh
 
paullas said:
hi

ok done that. but when i try and run it i get

: bad interpreter: No such file or directory

I am running it manual with this command ./delete.sh

try replacing the /bin/sh with /bin/bash.

I'm assuming you're using linux?

S
 
Try

delete.sh

rm -f /path/to/file/remove.file

chmod 777 delete.sh

./delete.sh
 
Status
Not open for further replies.

The Rule #1

Do not insult any other member. Be polite and do business. Thank you!

Members online

Premium Members

New Threads

Domain Forum Friends

Our Mods' Businesses

*the exceptional businesses of our esteemed moderators
General chit-chat
Help Users
  • No one is chatting at the moment.
      There are no messages in the current room.
      Top Bottom