Bluehost.com Web Hosting $6.95

schedule a script in crontab file problem

This is a discussion on schedule a script in crontab file problem within the Linux General forums, part of the Linux Forums category; I need to schedule a job to run the cleanup.ksh every 30 minutes. The cleanup.ksh will cleanup the ...


Go Back   Usenet Forums > Linux Forums > Linux General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 12-28-2004
jrefactors@hotmail.com
 
Posts: n/a
Default schedule a script in crontab file problem

I need to schedule a job to run the cleanup.ksh every 30 minutes. The
cleanup.ksh
will cleanup the files older than 30 minutes in
/appl/DEV_SERVER/proj/ftp/upload,
so that it has 30 minutes gap. Here's the script and how I modify the
crontab file,
but it still couldn't cleanup the files. If I execute the script
manually,
it works fine. Any ideas?? What am I missing here? suggestions?


#!/usr/bin/ksh
# filename: cleanup.ksh, cleanup ksh script
# usage: ksh cleanup n

find /appl/DEV_SERVER/proj/ftp/upload -type f -atime $1 -exec rm -f {}
\;


I did crontab -e, and add the following
30 0 * * 1-5 ksh /appl/proj/cronjob/cleanup.ksh +1/48
Please help. thanks!!

Reply With Quote
  #2 (permalink)  
Old 12-28-2004
Barry Margolin
 
Posts: n/a
Default Re: schedule a script in crontab file problem

In article <1104197156.048798.40880@z14g2000cwz.googlegroups. com>,
jrefactors@hotmail.com wrote:

> I need to schedule a job to run the cleanup.ksh every 30 minutes. The
> cleanup.ksh
> will cleanup the files older than 30 minutes in
> /appl/DEV_SERVER/proj/ftp/upload,
> so that it has 30 minutes gap. Here's the script and how I modify the
> crontab file,
> but it still couldn't cleanup the files. If I execute the script
> manually,
> it works fine. Any ideas?? What am I missing here? suggestions?
>
>
> #!/usr/bin/ksh
> # filename: cleanup.ksh, cleanup ksh script
> # usage: ksh cleanup n
>
> find /appl/DEV_SERVER/proj/ftp/upload -type f -atime $1 -exec rm -f {}
> \;
>
>
> I did crontab -e, and add the following
> 30 0 * * 1-5 ksh /appl/proj/cronjob/cleanup.ksh +1/48
> Please help. thanks!!


You scheduled it to run every weekday at 00:30. If you want it to run
every 30 minutes on weekdays, it should be:

0,30 * * * 1-5 ...

BTW, you don't need to put "ksh" in the crontab command line -- that's
done automatically due to the "#!/usr/bin/ksh" in the script.

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
Reply With Quote
  #3 (permalink)  
Old 12-28-2004
jrefactors@hotmail.com
 
Posts: n/a
Default Re: schedule a script in crontab file problem


Barry Margolin wrote:
> You scheduled it to run every weekday at 00:30. If you want it to

run
> every 30 minutes on weekdays, it should be:
>
> 0,30 * * * 1-5 ...
>
> BTW, you don't need to put "ksh" in the crontab command line --

that's
> done automatically due to the "#!/usr/bin/ksh" in the script.


Thanks Barry. so after I execute crontab -e, and do the editing, then
the updated crontab file will be effectively immediately?
please advise more. thanks

Reply With Quote
  #4 (permalink)  
Old 12-28-2004
Kenny McCormack
 
Posts: n/a
Default Re: schedule a script in crontab file problem

In article <1104255259.160255.157290@f14g2000cwb.googlegroups .com>,
<jrefactors@hotmail.com> wrote:
>
>Barry Margolin wrote:
>> You scheduled it to run every weekday at 00:30. If you want it to

>run
>> every 30 minutes on weekdays, it should be:
>>
>> 0,30 * * * 1-5 ...
>>
>> BTW, you don't need to put "ksh" in the crontab command line --

>that's
>> done automatically due to the "#!/usr/bin/ksh" in the script.

>
>Thanks Barry. so after I execute crontab -e, and do the editing, then
>the updated crontab file will be effectively immediately?
>please advise more. thanks


Use "crontab -l" to check.

Reply With Quote
  #5 (permalink)  
Old 12-28-2004
jrefactors@hotmail.com
 
Posts: n/a
Default Re: schedule a script in crontab file problem

yes, when I do crontab -l, I can see my changes in crontab.

ksh cleanup.ksh +1/48 should cleanup all files that are 30 minutes old.
correct? looks like
it is not working even i execute it manually. I want all files in
/appl/DEV_SERVER/proj/ftp/upload that are older than 30 minutes
are deleted. But if I do ksh cleanup.ksh -1/48, then it is fine.

Again, this is the script:

#!/usr/bin/ksh
# filename: cleanup.ksh, cleanup ksh script
# usage: ksh cleanup n

find /appl/DEV_SERVER/proj/ftp/upload -type f -atime $1 -exec rm -f {}
\;


please advise more. thanks!!

Reply With Quote
  #6 (permalink)  
Old 12-29-2004
Barry Margolin
 
Posts: n/a
Default Re: schedule a script in crontab file problem

In article <1104266338.914527.13140@z14g2000cwz.googlegroups. com>,
jrefactors@hotmail.com wrote:

> yes, when I do crontab -l, I can see my changes in crontab.
>
> ksh cleanup.ksh +1/48 should cleanup all files that are 30 minutes old.
> correct? looks like
> it is not working even i execute it manually. I want all files in
> /appl/DEV_SERVER/proj/ftp/upload that are older than 30 minutes
> are deleted. But if I do ksh cleanup.ksh -1/48, then it is fine.


I've never seen the '-atime +1/48' syntax in find before. I'm not aware
of find allowing fractions there. If you're using GNU find it has
-amin, which allows you to specify the amount of time in minutes rather
than days.

>
> Again, this is the script:
>
> #!/usr/bin/ksh
> # filename: cleanup.ksh, cleanup ksh script
> # usage: ksh cleanup n
>
> find /appl/DEV_SERVER/proj/ftp/upload -type f -atime $1 -exec rm -f {}
> \;
>
>
> please advise more. thanks!!


--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 06:09 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0