script to run monthly
Hi all,
Firstly I am new to bash script. I want to run this script every month (which is inside the forloop) and if should execute only execute when the $b matches $a.I want this count to be executed in both cases I am not sure if this is the right way to do it. can you please suggest. Code:
for VARIABLE in file1 |
Welcome.
You should look at cron instead. That is the normal way of scheduling a script to run on a recurring schedule. See 'man 5 crontab' and 'man 1 crontab' for the authoritative reference manuals. The reference manual pages are not tutorials but important to learn to navigate, so cross check them as you find tutorials online. Which distro is this for, including version? Also, if this is homework, then which additional information has been provided about the direction you should take in looking for a solution? |
Quote:
Hi, thanks for quick reply. I am running this script on ubuntu 14. Its not homework ofcourse. Yes to use the cronjob also, I am little confused how to do it. For example this script should run monthly and to run only on the particular month and date ( if condition should be matched ) not sure if i have to schedule cronjob twice? |
Quote:
There are always multiple ways to do things, but in this case you're not thinking things through...how is your script going to check if the dates match, if you don't actually RUN the script every day? And if you're manually running the script...what's the point of the date-check? As mentioned, cron can run things whenever you want...as an example: https://www.linuxquestions.org/quest...2/#post4654486 ...modify as you see fit. You then don't need the date-checks at all. |
Quote:
I'd lose the date construction and comparison (and the syntax errors in those lines). It forces this to have to run daily but only perform something useful on a specific month and day. Of course, if, for some reason, cron is not available... you'll have to correct those errors. Then you'll need to figure out how to schedule this script to run daily. "sleep 86400" at the end? Resubmit itself using something like "at -f $0 some-time-of-day tomorrow"? |
Quote:
|
Quote:
Code:
mkdir: cannot create directory ‘/dir/daily/’: File exists Code:
for VARIABLE in file1 |
Quote:
Quote:
|
If the mkdir target is dynamic e.g.
Code:
mkdir "$variable" Then you can avoid the error with a "dir exist" test Code:
[ -d "$variable" ] || mkdir "$variable" Or use the -p option Code:
mkdir -p "$variable" Code:
man mkdir |
All times are GMT -5. The time now is 01:32 PM. |