How can I set Plesk Crontab to only run a job on Friday?
Plesk seems to require every field to be filled. This makes sense in most cases, but I'm trying to have a job run only on every Friday night. How can I do this if the "Day of the Month" field can't be blank? If I enter a value for this field, for example "1", then won't the job run every Friday AND on the 1st of every month?
|
Not sure what Plesk is but are you saying it doesn't allow asterisk in that field like most other crontab implementations?
Try typing "man 5 crontab" if this is a Linux variant. |
Quote:
I can put an asterisk in the box, but that will mean every day of the month, won't it? If I do "Day of the Month: *" and "Day of the Week: Friday", will the cron job run every day of the month or just Fridays? |
Just Fridays!
|
Just Fridays when you have specified day of the week.
I understand the confusion though. If you had actual entries other than * in both fields it would run on both specifications. By putting the * though you're not telling WHEN to run - you're telling it it is ALLOWED it to run on every day so it then looks to the rest of the specification to determine when to run. |
Quote:
|
I think it is not possible. You can run every Friday and put a condition inside the script itself. For example check if the day of the month is in the first week or in the third week of the current month (you skip the second and the forth Friday). However it happens that a month has 5 Friday, so the problem is to run your script every 14 days, not only the first and third Friday of the month. In this case it would be better to create an empty file every time you execute the script and check if the current date is 14 days after the modification date of that file. You can also create a file containing the date in its name. For example:
Code:
#!/bin/bash |
There is no simple crontab setting that will that do what you want.
Has not been tested but it is supposed to check for even/odd weeks (0-53). So when %ON_WK=0 it is an even week. Setup crontab to run every Friday. #!/bin/sh WK=`date +%W` ON_WK=`expr $WK % 2` if [ $ON_WK = 0 ]; then do something constructive here. fi |
Thanks for your help! That's a good suggestion colucix to use the code to determine if it should run on a given week. michaelk, I like the idea of seeing if the week of the year is even or odd.
Plesk seems to have accepted day of the month: */2, day of the week: Friday and hasn't been running every other day. It's yet to be seen if it will run on every other Friday, but it's looking promising. I'll post what I find out. If it doesn't work, I'll have to add the code to the script that you guys are suggesting. Thanks again! |
Quote:
For others out there with the same question, here's the way to do it: Day of the Month: */2 Day of the Week: Friday |
Odd. I will try on my system. See you in two weeks... ;)
|
All times are GMT -5. The time now is 03:47 AM. |