If i understand you correctly you have the following situation:
- You have several servers and want to deploy crontab entries on them.
- The entries should get the local hostname as parameter.
First, i think you won't need to pass the hostname as a parameter because you could find it out inside the cron-script:
If you still want (for whatever reason) to put the hostname into the commandline write a deploy-script to create the crontab-entry. I am not sure where the crontabs are located in your Linux, so you might have to change the pathes a bit in the following, but the idea should be clear enough:
I have 2 scripts: script1 and script2
Script1 passes 4 parameters to script2 as follows
#script1
code
...
...
script2 $var1 $var2 $var3 $var4
Script2 uses the export command to know to expect these values
#script2
export $1 $2 $3 $4
code
...
...
The problem that I am having is... (1 Reply)
I have created a script "myscript.sh"
I need to run this script with diffrent parameters.
The parameters are stored in a file myparam.txt.
I need to run myscript.sh script for every parameter supplied in myparam.txt.
Example:
If myparam.txt contains following lines:
param1
param2
param3... (3 Replies)
hi,
i am passing around 14 parameters for a script
a=$1
b=$2
c=$3
d=$4
e=$5
f=$6
g=$7
h=$8
i=\"${9}\"
shift
j=\"${1}\"
still for j it is displaying the 1st parameter value..how to make it take the 10th parameter (2 Replies)
Hi,
The below script is working fine
awk1.sh
=======
awk BEGIN { FS="|" } FNR==NR { f1=$2; next } $1 in f1 && $2 =="xx" && $1 == "DAILY_JOB" {print $3}
awk -f awk1.sh a.txt b.txt--Its working fine .
When passing parameters its not working .Any help it should be appereciated.
... (4 Replies)
Hi All,
I am new to shell scripting required some help in passing the parameter value to the shell script.
I am writing a shell script, in the script I have created two functions as below.
first function
get_trend_ids () {
Here I am connecting to the database and getting all the... (3 Replies)
Hi All,
I have written a shell script and the script is working fine, I am passing my MIT_ID(NUMBER VALUE) to the shell script from the command prompt and my script is executing as expected.
Now I have to pass all the MIT_ID's from a .txt file to the shell script,as I am automating this I... (6 Replies)
how can i make a script to run only when parameters are given,
if parameters are not given it should through an error , saying "please enter a parameter"
for ex: i want a find command to run only when the parameters are given (4 Replies)
we are using following script to execute stored procedue. The problem is run_pmcmd.ksh script is using $*
parameter which is not taking in account 'Men Shirt' parameter which includes spaces.
1. Step 1
run_pmcmd.ksh CONVERT_TEST
script for run_pmcmd.ksh
/u01/$(whoami)/run_pmcmd.ksh... (11 Replies)
I have a script that uses more than one parameter. It looks like this:
for i in `cat /tmp/listofpolicies`;
do
for x in $(cat /tmp/lst |sed 's/^/\/usr\/openv\/netbackup\/db\/class\//g');
do /usr/openv/netbackup/bin/admincmd/bpplinclude $i -delete -f $x;done;done
The problem is that the... (3 Replies)
Hello Everyone,
I have developed a shell script which takes schema id and password as parameter to login into database using sqlplus,runs a query and mails the result.
My requirement is that, I dont want to pass userid and password as parameters.Instead,I want to pass say Environment... (4 Replies)
Discussion started by: karthik adiga
4 Replies
LEARN ABOUT CENTOS
crontab
CRONTAB(1) User Commands CRONTAB(1)NAME
crontab - maintains crontab files for individual users
SYNOPSIS
crontab [-u user] file
crontab [-u user] [-l | -r | -e] [-i] [-s]
crontab -n [ hostname ]
crontab -c
DESCRIPTION
Crontab is the program used to install, remove or list the tables used to serve the cron(8) daemon. Each user can have their own crontab,
and though these are files in /var/spool/, they are not intended to be edited directly. For SELinux in MLS mode, you can define more
crontabs for each range. For more information, see selinux(8).
In this version of Cron it is possible to use a network-mounted shared /var/spool/cron across a cluster of hosts and specify that only one
of the hosts should run the crontab jobs in the particular directory at any one time. You may also use crontab(1) from any of these hosts
to edit the same shared set of crontab files, and to set and query which host should run the crontab jobs.
Running cron jobs can be allowed or disallowed for different users. For this purpose, use the cron.allow and cron.deny files. If the
cron.allow file exists, a user must be listed in it to be allowed to use cron If the cron.allow file does not exist but the cron.deny file
does exist, then a user must not be listed in the cron.deny file in order to use cron. If neither of these files exists, only the super
user is allowed to use cron. Another way to restrict access to cron is to use PAM authentication in /etc/security/access.conf to set up
users, which are allowed or disallowed to use crontab or modify system cron jobs in the /etc/cron.d/ directory.
The temporary directory can be set in an environment variable. If it is not set by the user, the /tmp directory is used.
OPTIONS -u Appends the name of the user whose crontab is to be modified. If this option is not used, crontab examines "your" crontab, i.e.,
the crontab of the person executing the command. Note that su(8) may confuse crontab, thus, when executing commands under su(8) you
should always use the -u option. If no crontab exists for a particular user, it is created for him the first time the crontab -u
command is used under his username.
-l Displays the current crontab on standard output.
-r Removes the current crontab.
-e Edits the current crontab using the editor specified by the VISUAL or EDITOR environment variables. After you exit from the editor,
the modified crontab will be installed automatically.
-i This option modifies the -r option to prompt the user for a 'y/Y' response before actually removing the crontab.
-s Appends the current SELinux security context string as an MLS_LEVEL setting to the crontab file before editing / replacement occurs
- see the documentation of MLS_LEVEL in crontab(5).
-n This option is relevant only if cron(8) was started with the -c option, to enable clustering support. It is used to set the host in
the cluster which should run the jobs specified in the crontab files in the /var/spool/cron directory. If a hostname is supplied,
the host whose hostname returned by gethostname(2) matches the supplied hostname, will be selected to run the selected cron jobs
subsequently. If there is no host in the cluster matching the supplied hostname, or you explicitly specify an empty hostname, then
the selected jobs will not be run at all. If the hostname is omitted, the name of the local host returned by gethostname(2) is
used. Using this option has no effect on the /etc/crontab file and the files in the /etc/cron.d directory, which are always run,
and considered host-specific. For more information on clustering support, see cron(8).
-c This option is only relevant if cron(8) was started with the -c option, to enable clustering support. It is used to query which
host in the cluster is currently set to run the jobs specified in the crontab files in the directory /var/spool/cron , as set using
the -n option.
SEE ALSO crontab(5), cron(8)FILES
/etc/cron.allow
/etc/cron.deny
STANDARDS
The crontab command conforms to IEEE Std1003.2-1992 (``POSIX''). This new command syntax differs from previous versions of Vixie Cron, as
well as from the classic SVR3 syntax.
DIAGNOSTICS
An informative usage message appears if you run a crontab with a faulty command defined in it.
AUTHOR
Paul Vixie <vixie@isc.org>
Colin Dean <colin@colin-dean.org>
cronie 2012-11-22 CRONTAB(1)