rajeev2012
9th June 2007, 08:34
Hi
I want to automate a job but am not able to setup the same. PLease find below the steps that I am folllowing.
- I have created a job in company xxx having periodical and use external sched flag checked. (with user test - superuser)
- The relevant sessions have been added to this job
- The status of this job is "Free"
- In /var/spool/cron/crontabs/job file the following line is added
30 20 * * 1 $BSE/etc/rc.startjob xxx >>/home/test/job.log 2>>/home/test/job2.log
(The user "job" is linked to company 000)
- I did restart cron using /sbin/init.d/cron start command
It didn't work. The job has got executed (log files are created) but the linked sessions are not being executed.
Next, I though the problem would be the user "job" is linked to "000" company. Hence I tried to create a new file with same user name "test" in /var/spool/cron/crontabs/job and have copied the cotent of "job" into it and restart the cron. Still no luck.
I have seen many threads on the same topic in this forum but couldn't get the answer. It seems that I am missing out some thing, help appreciated ..
-Raj
rajeev2012
9th June 2007, 08:37
Please find below "rc.start"
#!/bin/sh
##########################################################################################
#
# RC.START Main part of rc.start
# VERSION 1996/04/10
#
# If rc.start executes successfully, the file ${BSE_TMP}/rc.start_done
# is created and the file ${BSE_TMP}/rc.stop_done is removed.
#
# 19940922LJ Test if user has logged on as root.
#
# 19950205LJ Test on root changed. 'id -u' not supported by UNIX-WARE.
# Changed in expression.
#
# 19960410RKl File rc.start broken down into separate units
#
# 19980902TVH IBM_AS400-port
#
# 19990726LJ Start Baan Login Daemon
#
##########################################################################################
BSE=/apps/extend
BSE_TMP=/apps/extend/tmp
export BSE BSE_TMP
# 040298:MBA
PLATFORM=`uname`
IBM_AS400="OS400"
Nl=/dev/null # The grinder
# This is a file on IBM_AS400
if [ $# -eq 0 ];then
licd_pdaemon=1
else
licd_pdaemon=0
fi
if [ ${PLATFORM} != ${IBM_AS400} ]
then
set `id 2>$Nl`
# test if user logged on as root
if expr "{$1}" : '^.*uid=0' >$Nl 2>&1
then :; else
echo "\nYou have to log on as root\n"
exit 1
fi
# if not an AS400
#test if you have *ALLOBJ and *SAVSYS special authorities
else
# IBM_AS400: there is a link to ckaut.pgm
$BSE/bin/chkaut
rc=$?
if [ ! $rc = 1 ]
then
echo "\You have to have *ALLOBJ and *SAVSYS authorities!\n"
exit 1
fi
fi
# the next sleep is built in for avoiding error 22 on HP systems.
echo 'Initializing...'
if [ ${PLATFORM} != ${IBM_AS400} ]
then
sleep 10
fi
# Initialize Shared Memory
${BSE}/etc/rc.start_shm
if [ $? -ne 0 ];then exit 1;fi
# Initialize Licence Daemon
if [ ${licd_pdaemon} -eq 1 ];then
${BSE}/etc/rc.start_licd
fi
# initialize Baan Login Daemon
${BSE}/etc/rc.start_blogind
if [ $? -ne 0 ];then exit 1;fi
# Load Runtime DD in Shared Memory
${BSE}/etc/rc.start_srdd
#Optional Remove all Application Locks
#${BSE}/etc/rc.start_remall
# Initialize Printer Daemon
if [ ${licd_pdaemon} -eq 1 ];then
${BSE}/etc/rc.start_pdaemon
fi
#Optional to start the jobdaemon.
#${BSE}/etc/rc.startjobdm
rm -f ${BSE_TMP}/rc.stop_done
echo "The script rc.start executed sucessfully" > ${BSE_TMP}/rc.start_done
# end
Markus Schmitz
11th June 2007, 12:02
Hi,
inprincipal you are on the right track. Here is what you do, if you want croin for scheduling jobs in Baan:
a) For each company, where you want to run jobs, create a user, job000, job100, job500 etc.
b) Test for each user, whether you can log onto Baan and have appropriate Super User rights.
c) For each user, create a crontab, with the script you listed already.
d) Restart cron or edit the crontab with crontab -e, depending on your Unix derivat.
e) Make sure the user is allowed to use cron (cron.allow).
Post the rc.startjob file here to have a look. The rc.start file is of now interest, in this matter.
Regards
Markus
rajeev2012
11th June 2007, 12:45
Hi,
Thanks for your input...
- I believe the first threee points (a,b, c and d), i have already covered. I suppose "job" is not a mandatory word in user name (in my case it is "test"). Please let me know in case you find any issues with it.
- I have added "test" in cron.allow file.
[code]
PLease find below rc.startjob script
# rc.startjob, should be located in $BSE/etc
# version 94/06/29 (Erwin Derksen)
# * added setting of TERM to this file
# version 94/04/21 (initial version)
#
# script to start a job in the background
# BAMODE=1 : No output to screen.
# Be sure to define the BSE, BSE_TMP and PATH variable, because when started
# from the crontab these variables often are not defined
BSE=/apps/extend
BSE_TMP=/apps/extend/tmp
export BSE BSE_TMP
PATH=$BSE/bin:$PATH
export PATH
# It turned out that the TERM variable could be unset when running in a cron
TERM=vt100 ;export TERM
# If you want to use several companies you can create several users for e.g.
# root who probably is running this script. If so, copy this script and use
# the next line to define the USER variable (<root100> is just an example).
#USER=<root100> ;export USER
if [ $# -lt 1 ];then
echo "Usage : rc.startjob <jobname> [jobok_file]"
exit 1
fi
if [ $1 = "-U" -o $1 = "-u" ];then
echo "Usage : rc.startjob <jobname> [jobok_file]"
exit 1
fi
#jobok_file contains the characters "OK" if the job was successful !
#If jobok_file is not specified, then output is written to $BSE/tmp/job
BAMODE=1 ;export BAMODE
DS_SERVER=ba ;export DS_SERVER
BSH_JOB=$1 ;export BSH_JOB
if [ $# -gt 1 ];then
BSH_JOBOK=$2 ;export BSH_JOBOK
echo $BSH_JOBOK
fi
ba6.2 ttaad5203m000 2>${BSE_TMP}/rc.startjoberr &
[code]
Markus Schmitz
11th June 2007, 12:58
ba6.2 ttaad5203m000 2>${BSE_TMP}/rc.startjoberr &
The script looks good. So what does rc.startjoberr say?
rajeev2012
11th June 2007, 14:12
The rc.startjoberr has only following two lines:
"Connecting with bshell...
Connection established."
Markus Schmitz
11th June 2007, 14:14
Make sure, that the rc.startjoberr is not an old one, by deleting it first.
The content looks correct, so:
a) Did you check logs in $EBSE/log
b) Is the job at all started in Baan, what does the job history say?
rajeev2012
11th June 2007, 18:32
I have also tried to run the job from command lione but it didn't work. I have tried the following command:
sh rc.startjob XXX >>/home/test/job.log 2>>/home/test/job2.log
"job.log" is balnk and job2.log has followed line:
/apps/extend/tmp/rc.startjoberr: Cannot create the specified file.
hence, i beileve something is wrong with my setup ...
Please let me know your views
Markus Schmitz
11th June 2007, 18:36
ok, that clarifies a lot and you should have the same message in the mail of the corresponding user.
It also mean, that your BSE_TMP is pointing to /apps/extend/tmp, which is a bit non-standard, but ok.
Simply correct (as user root) the ownership and permissions of the directory:
chown -R bsp:bsp /apps/extend/tmp
chmod -R 775 /apps/extend/tmp
Regards
Markus
rajeev2012
12th June 2007, 10:45
Hi Markus,
I have made th said changes and have managed to get the job run manually (through commandline). However, still I am not succeed to get it automated. I think the problem would be company or access/permission.
-Raj
Markus Schmitz
12th June 2007, 11:41
If it runs manually from the shell, then you took a big hurdle.
One reason, why these things then opften fail to run from cron, are simply environment settings. When you log into unix, a ton of enviornment variables are set (type env to see, depending on the shell you arer using). These enviornment variables are missing within cron. So you have to set them within the rc.startjob script. For example missing oracle enviornment variables could be the cause.
Regards
Markus
rajeev2012
12th June 2007, 15:27
Hi Markus
Another scheduled jobs (patch management related) work for another user "job" ( the only difference is "job" is linked to "000" company)
Howevere, I will check and will get back to you with my findings.
-Raj
rajeev2012
12th June 2007, 16:15
I have compared output of env command of "root" and "test" user. I hav efound couple of difference, listed below
- for root "PATH" variable has an extra entry "/usr/sbin:" that is missing in "test"
- for root SHELL=/usr/bin/ksh wheras for "test" it is SHELL=/usr/bin/sh
I am not sure about the first difference but i feel teh later doesn't make any difference (as i tried sh as well as ksh command for manual job activation and uit worked).
-Raj
rajeev2012
13th June 2007, 12:56
I am still stuck with it, any clue what am i missing ?
rajeev2012
15th June 2007, 10:56
Thanks a lot for all your input. I have managed to get it worked. I was making a small mistake. I had created "crontab" file by copying the old existing file. Hence, I suppose all relevant fiels were not being updated with the same. Now, I have removed the "crontab" file and have created a new "crontab" file with the followed command "crontab -e" using "test" login.
Though, it's woking, I am still curious to know which file was not getting updated and causing the issue.
-Raj