I would like to set-up a script in cron on a Solaris 10 sever which would run once in 3 weeks. I am not supposed to make any changes in the script itself.
Can anyone advise how it can be done?
For any queries, kindly let me know.
I don't have access to a Solaris machine and have no idea how cron on Solaris works. Right now I'm working on RHEL GNU Bash.
Here's one way to do it. You need not make any changes to the original script. You can write a wrapper script and have a tmp file containing the date of first run (date in tmp file should be in yyyymmdd format). Place this wrapper script and tmp file in same directory.
Wrapper script: A condition checks if the difference between current date and the date in tmp file is 21. If yes, run original script and change date in file to current date.
The below code is untested.
Now for the cron entry (Invoke wrapper script every monday at 9am):
Thanks for the above suggestion.
But .. since this is a restricted environment (client setup) I am not allowed to place my scripts on it, so I have to do it with cron.
If you would have done it on GNU, how would you do it with cron and not with script?
A few suggestions (to test out) would be appreciated!.
Thanks.
One way without a wrapper script and temporary file could be checking if the number of weeks since 1970-01-01 is divisible by 3. The crontab entry for every 3rd monday at 9 am:
From the sort of answers you are getting this is ambiguous.
Do you want to run this existing script once only on a specific date and time in three weeks time?
If that is true, I would use an "at" job (which uses cron). See "man at".
OR:
Do you want you run this existing script every third week at a specified time for evermore?
This crontab line will not work in Solaris because the default Shell for cron is the old Bourne Shell which does not support $(( )) syntax.
Also it contains a percentage sign "%" which is a special character in crontab files on all platforms.
This crontab line will not work in Solaris because the default Shell for cron is the old Bourne Shell which does not support $(( )) syntax.
Also it contains a percentage sign "%" which is a special character in crontab files on all platforms.
Hmm, the calculation could be done using bc, but the problem with the percentage sign still remains, which makes an approach using the date command futile...
Hi I want to set up a cron for every 15 minutes between some hours.
Can you tell whether the below command will work.
Getting confuse because my time goes from night to next day morning.
i want to setup 8 PM to next day 10 AM.
*/15 20-10 * * * sh abc.sh (1 Reply)
Hi,
I am looking for a shell script which serves the below purpose.
Please find below the algorithm for the same and any help on this would be highly appreciated.
1)set of strings need to be replaced among set of files(directory may contain different types of files)
2)It should search for... (10 Replies)
Hi,
I have a Solaris (SunOS 5.10) installed, by default with the en_AU.UTF-8 locale. I want to change it to en_US.UTF-8
With AU, I have no issues whatsoever, so I installed the language package and now locale -a shows "en_US.UTF-8".
Problem is even with LC_ALL set in etc/default/init, the... (2 Replies)
Hello, I need to write a program which sets server's ip address, router, network mask. Program also should set if it is an internal or external ip. Maybe someone can help me ? Any information from u is very useful :b:
I stopped at .. :(
#!/bin/sh
A=`hostname -i`
echo "server ip address is $A"... (4 Replies)
Hello All,
Hopw all is fine. I am newbie to Unix. I am using Bourne Shell (sh). One of the question I have is that I am trying to read XML file and based on reading that XML file I want to run different java programs at different hours. Meaning
05 14 * * * java ./program1
10 14 * * * java... (3 Replies)
Hi All,
I am running a script , working very fine on cmd prompt. The problem is that when I open do crontab -e even after setting editor to vi by
set EDITOR=vi it does not open a vi editor , rather it do as below.....
/////////////////////////////////////////////////////
$ set... (6 Replies)
i have written shell script that script has path to java programwhen irun this script in terminal i get the output but when irun in cron it gives me eror.plz send me code to set classpath
#! /bin/bash
javac Copy.java
/usr/bin/java Copy
plz help me out
how should i write classpath... (1 Reply)
Under this directory:
/var/spool/cron/crontabs/
I have the following users:
adm lp oracle root sys uucp
I believe who are able to start a cron job.
I am trying to create a cronjob under user banjob so that it can delete files older than 30 days.
How can I add user banjob... (4 Replies)