• Welcome to AcornDomains.co.uk, a friendly community for UK domain investors, developers and anyone interested in domain names.

    Whether you're looking to buy or sell domains, learn more about the UK domain market, get feedback on your names, or simply chat with other domainers, you're in the right place. AcornDomains has been bringing together people from across the UK domain industry for many years, from complete beginners to experienced investors.

    Have a look around, join the discussions and, if you haven't already, create a free account and introduce yourself.

cron job help

Status
Not open for further replies.

PaullasPaullas is verified member.

Acorn Moderator
Nominet Member
Nominet Registrar
Hosting Provider
Domain Marketplace
Parking Service
Joined
Jul 13, 2004
Posts
5,928
Reaction score
467
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.
Top Bottom