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 ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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!! |
|
|||
|
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 *** |
|
|||
|
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 |
|
|||
|
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. |
|
|||
|
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!! |
|
|||
|
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 *** |