Thankyou very much!
Yes, I’ll fire it from a crontab entry: so you suggest (if I’ve understood correctly: sorry but my english is not perfect…) to punt just a “$1” in the if and to add che date function to che cron line. Right?
In a cron job’s rule you can just say when the script is to be run. The fields are
min hour date month weekday
followed by the command (but there is a 6th field for the user in system crontabs, so watch out). So you don’t have to do any day testing in the script at all.
ok, but if I want different tar options according to the day of the week I suppose I have to make a test somewere…or not?
The cron should just run the script, with no options…
Thankyou very much for your answer and for you patience!
Is it possible to do something like this:
12 2 * * 1-7 root do-backup <arguments>
and put as <argument> the function that retrieves the day of the week?
So in the script I’d just make the test as an “if $0…” and I can test the script manually passing the argument!
Well that line is interpreted like a command typed to the shell so you could put a date command in backticks there, but that defeats the purpose of taking the test out of the script, you’ve just executed the date command somewhere else. (And you have to watch out for %, which is special in crontabs, see the manual page.) Since you only have two cases, incremental and full, I think it is simpler to have two lines in the crontab.
Also * is the same as 1-7 in the weekday field.
And $0 is not the first argument, it’s the name of the script itself.
It depends on the error. It could be a syntax error, or the result could be anything unexpected. You can’t rely on a wrong program to produce any particular result.