Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Removing a file 1

Status
Not open for further replies.

arjagadish

Technical User
Jan 6, 2003
36
0
0
IN
Hi guyz,

How to use the cron or cron tab. I need to remove a file in the root folder every 15minutes.
 
Thx Man,

So would this work:

crontab -e

0,15,30,45 * * * 0-6 rm -rf /root/{filename}



 
That'll work fine - nb 0-6 = every day, so **** would be more usual.
Our standards at this shop dictate that cron calls scripts
and not commands (its better - more control etc etc blah blah)
so I'd do:
0,15,30,45 * * * * /scripts/rmjob

and the script rmjob would look like
!#/bin/ksh
rm -rf /root/filename


HTH




Dickie Bird (:)-)))
 
Thx for the reply guys...........

But it's not working. Do I have to start the CRON service or something...........

If so tell me how to do it.

 
You will need to make sure:

[1] That the crond process is running. This process is responsinle for checking each user's crontab, and executing any of the scripts that need running.

[2] That your user has permission to run cron jobs. From the crontab man pages:

[ignore]
crontab Access Control
Users: Access to crontab is allowed:

o if the user's name appears in /etc/cron.d/cron.allow.

o if /etc/cron.d/cron.allow does not exist and the
user's name is not in /etc/cron.d/cron.deny.

Users: Access to crontab is denied:

o if /etc/cron.d/cron.allow exists and the user's name
is not in it.

o if /etc/cron.d/cron.allow does not exist and user's
name is in /etc/cron.d/cron.deny.

o if neither file exists, only a user with the
solaris.jobs.user authorization is allowed to submit a
job.
[/ignore]

Hope this helps. :)
 
ps: while testing, I would be extremely careful with the use of rm -rf if I were you. For example:
Code:
rm -rf /$FOO
If [tt]$FOO[/tt] is not set, this becomes:
Code:
rm -rf /
[bugeyed]
I would suggest testing cron with a less dangerous command first...
 
Well, actually, it was a mistake from my side.

I had put the command in a script,But I had not made the script executable(chmod +x)........... so it was giving me Permission/Access Denied error.

Anyways, it;s working fine now.

Cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top