I have sevaral jbos with bunch of export commands like export VARIABLE=value.
They work perfectly when I run manually but when I try to run from crontab it stops right at this export command.
But when I replace these export with these, crontab job works fine.
VARIABLE = value; export VARIABLE.
Is there a way to make crontab job work with the orginal way of exporting ( export VARIABLE=value). I have 100+ like this and don't want to send time modifying all these.
Well,
is a bash/ksh form. Many commands and systems like cron default you to sh, where you can't say that, but must say:
If you are in csh, I think it is
or the like. Your crontab line can say
or
but the slick thing is to make your script execvp() friendly: execuatable
and with the first line
so cron's sh execvp()'s it over to the right interpreter. You can make a sed script, for instance, with
as the first line, since sed does not expect scripts by default, only under the -f option. For bash,
is all you need, as it expects script names. Don't forget or innovate, as execvp() is not imaginative. Verify the interpreter path with something like "which bash". As man execvp says, if you mess up, you get
which can be disappointing in many ways!
Last edited by DGPickett; 02-22-2012 at 05:48 PM..
@MKNENI
In Solaris the Shell used by cron is /usr/bin/sh which is one which does not allow the "export variable=value" syntax.
There are two solutions.
1) Prepend a shebang line for your normal shell to every script
2) Invoke your normal shell from the cron command line
e.g.
/usr/bin/ksh /pathtoscript/scriptname
hell all:
i am trying to test a crontab job for snmpwalk but it is not working:
here is crontab:
*/1 * * * * root /root/snmpwalk.sh
for the script, it is very simple:
#!/usr/local/bin/bash
/usr/local/bin/snmpwalk -v 2c -c public 100.10.10.10 (6 Replies)
Hello,
This is my first posting in Linux world.
I have SLES 11.
I've created a file 'packdisk-scandisk.txt' file under /var/opt/Teradata/bteqdba.
The content of the file is,
cat /var/opt/Teradata/bteqdba/packdisk-scandisk.txt
output over /var/opt/Teradata/bteqdba/TAREAS_DBA.log... (2 Replies)
I have a ksh script that does the following
1. Script executes and creates an output file from a sql query
2. That output file is an input file to the script
3. generates an html file to email to DBA receipients
The following syntax works at the command line
... (1 Reply)
I wrote a quick little script that will eventually end up as a cron job to export rrd files for my cacti server.
Here is the script:
#!/bin/bash
rm -rf /backup/cacti_xml/*
cd /var/www/html/rra
ls -1 *.rrd | awk '{print "rrdtool dump "$1" > /backup/cacti_xml/"$1".xml"}' | sh -x
Is there... (5 Replies)
I am having some issues with my cronjobs not running in solaris 10.
Cron is running:
~> ps -ef | grep cron
root 202 1 0 Jul 18 ? 0:01 /usr/sbin/cron
bender 1646 1562 0 01:57:49 syscon 0:00 grep cron
crontab -l lists the cronjob and I *think* its in the... (8 Replies)
Hi all,
down here part of the scheduled job in crontab (AIX Version 5)
i have problem running jspPRE-ALL.
i verrify permissions and privileges (the others job are working good)
if i run the job in command line it work correctly
#
# Aggiornamento doni e continuity
00 02 * * 2-6... (5 Replies)
Hello Gurus,
I've been tasked with solving a problem at my new job and I'm stumped. We've got a script that dynamically builds an oracle export parameter files and then runs export from the shell. it runs fine when using the shell, but will NOT run (fails in one spot everytime) when entered... (1 Reply)
Hi,
i need to schedule a script to run at 6.10AM everyday.I tried to do this way.
#!bin/ksh
10 06 * * 0-6
sh /tmp/ss/script/daily_file_check.sh
And at the command prompt I did
>crontab -e cron.txt
I'm not sure whether this is the right way.
Can anyone please tell me how to... (4 Replies)
Hi,
I have cornjob was scheduled at 1:00 AM everyday. It has been running fine since last Saturday. But it didn't run since Saturday. Because of daytime saving time change it didn't ran?
Please send me your thoughts.
Thanks in adavance.
Moe (3 Replies)