Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2004 07:51 PM
12-06-2004 07:51 PM
I have a script called run_sftp for transfering a file to another server.The script run_sftp will call a script called sftp. sftp script is using expect instead shell.
When I run it manually, it was running perfectly. But when run it through cronjob, it is not running fine. Nothing on cron log, but the file can not be transfered.
Is it the issue with the environment? How can I make it run through crontab? Pls help. High score will be given.
Thanks and Best Regards,
Negara
# crontab -l|grep sftp
37 3 * * * /opt/sapapp/L6A/SC/scripts/transfer/run_sftp > /tmp/sftp 2>&1
#more /var/adm/cron/log
> CMD: /opt/sapapp/L6A/SC/scripts/transfer/run_sftp > /tmp/sftp 2>&1
> root 16884 c Tue Dec 7 03:37:00 EST 2004
< root 16884 c Tue Dec 7 03:37:15 EST 2004
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2004 07:59 PM
12-06-2004 07:59 PM
Solutionusually if you can run manually but not through cron it goes back to environment initialisation. Cron does not run profile therefore it's up to you to initialise the variables in the script.
we have a profile.cron for cron processing.
a script run through cron would be wrapped with another script to initialise required variables.
Regards
Jean-Luc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2004 08:00 PM
12-06-2004 08:00 PM
Re: Cron job
it is probably the missing environment. Try first to look for clues in the mail for the user who executes the cron job.
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2004 08:06 PM
12-06-2004 08:06 PM
Re: Cron job
when you are running script ,you are giving the user name & passwd manually?
if it is like that,just make a file .netrc in your users home directory(who is running this script) with the contents like following.(change the entries as per your server .change ip address ,user name which comes after login and passwd)
machine 192.99.3.3 login dba password india
machine 172.25.2.2 login sa password jk123
machine 172.25.3.50 login ora1 password jk456
then run cron
regds,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2004 08:17 PM
12-06-2004 08:17 PM
Re: Cron job
Thanks alot. I am not using .netrc, but using expect script to transfer the file without public/private keys. I attach the script below. I have tried to change the environment, but still can not solve the issue. Pls help. Thanks alot.
Regards,
Dewa
[root@prod:/opt/sapapp/L6A/SC/scripts/transfer]
# ll
total 10
-rw-r--r-- 1 root sys 9 Dec 1 21:55 .password
-rw-r--r-- 1 root sys 97 Dec 7 02:22 batchFile
-rwx------ 1 root sys 122 Dec 7 04:03 run_sftp
-rwx------ 1 root sys 495 Dec 2 02:03 sftp
[root@prod:/opt/sapapp/L6A/SC/scripts/transfer]
# more run_sftp
#!/usr/bin/sh -x
. /opt/soeg/bin/setup_env.sh /opt/soeg/conf/env_vars.conf
cd /opt/sapapp/L6A/SC/scripts/transfer
./sftp
[root@prod:/opt/sapapp/L6A/SC/scripts/transfer]
# more sftp
#!/usr/local/bin/expect
# Initialisation
set authFile "/opt/sapapp/L6A/SC/scripts/transfer/.password"
# Check the authorisation file exists
if {![file exists $authFile]} { ;# Does file exist
send_user "$authFile does not exist; aborting\n"
exit 1
}
set fileFD [open $authFile r] ;# Open the auth file
gets $fileFD authLine ;# Read in 1 line to authLine
close $fileFD
# Transfer file(s)
spawn sftp -b batchFile importve@www.importve.com
expect "password:"
send "$authLine\n";
interact
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2004 08:30 PM
12-06-2004 08:30 PM
Re: Cron job
Regards,
Fred
"Reality is just a point of view." (P. K. D.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2004 08:34 PM
12-06-2004 08:34 PM
Re: Cron job
1) Content of /tmp/sftp when running trhough crontab:
[root@prod:/var/adm]
# more /tmp/sftp
+ . /opt/soeg/bin/setup_env.sh /opt/soeg/conf/env_vars.conf
+ [[ /opt/soeg/conf/env_vars.conf = -help ]]
+ [[ 1 != 1 ]]
+ [[ ! -a /opt/soeg/conf/env_vars.conf ]]
+ cat /opt/soeg/conf/env_vars.conf
+ read -r Env_variable Value
+ export SOE=/opt/soeg
+ read -r Env_variable Value
+ export SOEG=/opt/soeg
+ read -r Env_variable Value
+ export SOEAPPINST=/usr/local/applications
+ read -r Env_variable Value
+ export SOEAPPCONF=/usr/local/applications/conf
+ read -r Env_variable Value
+ export SOESTARTSTOP=/usr/local/applications/startstop
+ read -r Env_variable Value
+ export SOEBIN=/opt/soeg/bin
+ read -r Env_variable Value
+ export SOEDOC=/opt/soeg/doc
+ read -r Env_variable Value
+ export SOECONF=/opt/soeg/conf
+ read -r Env_variable Value
+ export SOEINSTCONF=/opt/soeg/install/conf
+ read -r Env_variable Value
+ export SOELOG=/var/opt/soeg/log
+ read -r Env_variable Value
+ export SOERPT=/var/opt/soeg/rpt
+ read -r Env_variable Value
+ export SOEDATA=/opt/soeg/data
+ read -r Env_variable Value
+ export SOEBKUP=/var/opt/soeg/sys_snapshot
+ read -r Env_variable Value
+ export SOESEC=/opt/soeg/sectools
+ read -r Env_variable Value
+ export SOESECRPT=/var/opt/soeg/sectools/rpt
+ read -r Env_variable Value
+ export SAVENODE=/var/opt/soeg/savenode
+ read -r Env_variable Value
+ export BKP_LOG=/var/opt/soeg/log
+ read -r Env_variable Value
+ export RECOVERY=/opt/soeg/recovery
+ read -r Env_variable Value
+ export RECOVERYBIN=/opt/soeg/recovery/bin
+ read -r Env_variable Value
+ export RECOVERYLOG=/var/opt/soeg/recovery/log
+ read -r Env_variable Value
+ export RECOVERYRPT=/var/opt/soeg/recovery/rpt
+ read -r Env_variable Value
+ export RECOVERYDOC=/opt/soeg/recovery/doc
+ read -r Env_variable Value
+ export RECOVERYCONF=/opt/soeg/recovery/conf
+ read -r Env_variable Value
+ export RECOVERYDATA=/opt/soeg/recovery/data
+ read -r Env_variable Value
+ export PERF=/var/opt/perf
+ read -r Env_variable Value
+ export PERFLOG=/var/opt/perf/datafiles
+ read -r Env_variable Value
+ export SUPPORTW=/opt/soeg/supportw
+ read -r Env_variable Value
+ export SUPPORTWBIN=/opt/soeg/supportw/bin
+ read -r Env_variable Value
+ export SUPPORTWLOG=/var/opt/soeg/supportw/log
+ read -r Env_variable Value
+ export SUPPORTWRPT=/var/opt/soeg/supportw/rpt
+ read -r Env_variable Value
+ export SUPPORTWDOC=/opt/soeg/supportw/doc
+ read -r Env_variable Value
+ export SUPPORTWCONF=/opt/soeg/supportw/conf
+ read -r Env_variable Value
+ export SUPPORTWDATA=/opt/soeg/supportw/data
+ read -r Env_variable Value
+ export SYSMGR=/usr/local/sysmgr
+ read -r Env_variable Value
+ export SOEINST=/opt/soeg/install
+ read -r Env_variable Value
+ export SOEINSTBIN=/opt/soeg/install/bin
+ read -r Env_variable Value
+ export SOEINSTLOG=/var/opt/soeg/install/log
+ read -r Env_variable Value
+ export APPSTDS=/usr/local/applications/app_stds
+ read -r Env_variable Value
+ export CONTROLM=/opt/ctms/ctm
+ read -r Env_variable Value
+ export SYBASE=/opt/ctms/ctm/sybase
+ read -r Env_variable Value
+ export DSLISTEN=CTRLM
+ read -r Env_variable Value
+ export DSQUERY=CTRLM
+ read -r Env_variable Value
+ export DSCONSOLE=CTRLM
+ read -r Env_variable Value
+ export CONTROLM_USER=ctms
+ read -r Env_variable Value
+ export CONTROLM_DATABASE=ctms
+ read -r Env_variable Value
+ export NDMAPICFG=/opt/cdirect/ndm/cfg/cliapi/ndmapi.cfg
+ read -r Env_variable Value
+ export NBBIN=/usr/openv/netbackup/bin
+ read -r Env_variable Value
+ export NBCONF=/usr/openv/netbackup/conf
+ read -r Env_variable Value
+ export NBLOG=/usr/openv/netbackup/logs/bp_notify
+ read -r Env_variable Value
+ cd /opt/sapapp/L6A/SC/scripts/transfer
+ ./sftp
spawn sftp -b batchFile importve@www.importve.com
spawn sftp -b batchFile importve@www.importve.com
spawn sftp -b batchFile importve@www.importve.com
spawn sftp -b batchFile importve@www.importve.com
spawn sftp -b batchFile importve@www.importve.com
spawn sftp -b batchFile importve@www.importve.com
spawn sftp -b batchFile importve@www.importve.com
spawn sftp -b batchFile importve@www.importve.com
spawn sftp -b batchFile importve@www.importve.com
spawn sftp -b batchFile importve@www.importve.com
spawn sftp -b batchFile importve@www.importve.com
spawn sftp -b batchFile importve@www.importve.com
spawn sftp -b batchFile importve@www.importve.com
spawn sftp -b batchFile importve@www.importve.com
spawn sftp -b batchFile importve@www.importve.com
spawn sftp -b batchFile importve@www.importve.com
spawn sftp -b batchFile importve@www.importve.com
spawn sftp -b batchFile importve@www.importve.com
spawn sftp -b batchFile importve@www.importve.com
spawn sftp -b batchFile importve@www.importve.com
spawn sftp -b batchFile importve@www.importve.com
spawn sftp -b batchFile importve@www.importve.com
spawn sftp -b batchFile importve@www.importve.com
spawn sftp -b batchFile importve@www.importve.com
spawn sftp -b batchFile importve@www.importve.com
spawn sftp -b batchFile importve@www.importve.com
spawn sftp -b batchFile importve@www.importve.com
spawn sftp -b batchFile importve@www.importve.com
spawn sftp -b batchFile importve@www.importve.com
spawn sftp -b batchFile importve@www.importve.com
spawn sftp -b batchFile importve@www.importve.com
spawn sftp -b batchFile importve@www.importve.com
spawn sftp -b batchFile importve@www.importve.com
spawn sftp -b batchFile importve@www.importve.com
spawn sftp -b batchFile importve@www.importve.com
spawn sftp -b batchFile importve@www.importve.com
spawn sftp -b batchFileymhung04
2) Content of /tmp/sftp when running manually:
[root@prod:/var/adm]
# more /tmp/sftp
+ . /opt/soeg/bin/setup_env.sh /opt/soeg/conf/env_vars.conf
+ [[ /opt/soeg/conf/env_vars.conf = -help ]]
+ [[ 1 != 1 ]]
+ [[ ! -a /opt/soeg/conf/env_vars.conf ]]
+ read -r Env_variable Value
+ cat /opt/soeg/conf/env_vars.conf
+ export SOE=/opt/soeg
+ read -r Env_variable Value
+ export SOEG=/opt/soeg
+ read -r Env_variable Value
+ export SOEAPPINST=/usr/local/applications
+ read -r Env_variable Value
+ export SOEAPPCONF=/usr/local/applications/conf
+ read -r Env_variable Value
+ export SOESTARTSTOP=/usr/local/applications/startstop
+ read -r Env_variable Value
+ export SOEBIN=/opt/soeg/bin
+ read -r Env_variable Value
+ export SOEDOC=/opt/soeg/doc
+ read -r Env_variable Value
+ export SOECONF=/opt/soeg/conf
+ read -r Env_variable Value
+ export SOEINSTCONF=/opt/soeg/install/conf
+ read -r Env_variable Value
+ export SOELOG=/var/opt/soeg/log
+ read -r Env_variable Value
+ export SOERPT=/var/opt/soeg/rpt
+ read -r Env_variable Value
+ export SOEDATA=/opt/soeg/data
+ read -r Env_variable Value
+ export SOEBKUP=/var/opt/soeg/sys_snapshot
+ read -r Env_variable Value
+ export SOESEC=/opt/soeg/sectools
+ read -r Env_variable Value
+ export SOESECRPT=/var/opt/soeg/sectools/rpt
+ read -r Env_variable Value
+ export SAVENODE=/var/opt/soeg/savenode
+ read -r Env_variable Value
+ export BKP_LOG=/var/opt/soeg/log
+ read -r Env_variable Value
+ export RECOVERY=/opt/soeg/recovery
+ read -r Env_variable Value
+ export RECOVERYBIN=/opt/soeg/recovery/bin
+ read -r Env_variable Value
+ export RECOVERYLOG=/var/opt/soeg/recovery/log
+ read -r Env_variable Value
+ export RECOVERYRPT=/var/opt/soeg/recovery/rpt
+ read -r Env_variable Value
+ export RECOVERYDOC=/opt/soeg/recovery/doc
+ read -r Env_variable Value
+ export RECOVERYCONF=/opt/soeg/recovery/conf
+ read -r Env_variable Value
+ export RECOVERYDATA=/opt/soeg/recovery/data
+ read -r Env_variable Value
+ export PERF=/var/opt/perf
+ read -r Env_variable Value
+ export PERFLOG=/var/opt/perf/datafiles
+ read -r Env_variable Value
+ export SUPPORTW=/opt/soeg/supportw
+ read -r Env_variable Value
+ export SUPPORTWBIN=/opt/soeg/supportw/bin
+ read -r Env_variable Value
+ export SUPPORTWLOG=/var/opt/soeg/supportw/log
+ read -r Env_variable Value
+ export SUPPORTWRPT=/var/opt/soeg/supportw/rpt
+ read -r Env_variable Value
+ export SUPPORTWDOC=/opt/soeg/supportw/doc
+ read -r Env_variable Value
+ export SUPPORTWCONF=/opt/soeg/supportw/conf
+ read -r Env_variable Value
+ export SUPPORTWDATA=/opt/soeg/supportw/data
+ read -r Env_variable Value
+ export SYSMGR=/usr/local/sysmgr
+ read -r Env_variable Value
+ export SOEINST=/opt/soeg/install
+ read -r Env_variable Value
+ export SOEINSTBIN=/opt/soeg/install/bin
+ read -r Env_variable Value
+ export SOEINSTLOG=/var/opt/soeg/install/log
+ read -r Env_variable Value
+ export APPSTDS=/usr/local/applications/app_stds
+ read -r Env_variable Value
+ export CONTROLM=/opt/ctms/ctm
+ read -r Env_variable Value
+ export SYBASE=/opt/ctms/ctm/sybase
+ read -r Env_variable Value
+ export DSLISTEN=CTRLM
+ read -r Env_variable Value
+ export DSQUERY=CTRLM
+ read -r Env_variable Value
+ export DSCONSOLE=CTRLM
+ read -r Env_variable Value
+ export CONTROLM_USER=ctms
+ read -r Env_variable Value
+ export CONTROLM_DATABASE=ctms
+ read -r Env_variable Value
+ export NDMAPICFG=/opt/cdirect/ndm/cfg/cliapi/ndmapi.cfg
+ read -r Env_variable Value
+ export NBBIN=/usr/openv/netbackup/bin
+ read -r Env_variable Value
+ export NBCONF=/usr/openv/netbackup/conf
+ read -r Env_variable Value
+ export NBLOG=/usr/openv/netbackup/logs/bp_notify
+ read -r Env_variable Value
+ cd /opt/sapapp/L6A/SC/scripts/transfer
+ ./sftp
spawn sftp -b batchFile importve@www.importve.com
Connecting to www.importve.com...
importve@www.importve.com's password:
sftp> lcd /opt/sapapp/L6A/SC/data/Venezuela/Purchases
sftp> cd /data/web/90558/www/sap/
sftp> put Purchase.txt
Uploading Purchase.txt to /data/web/90558/www/sap/Purchase.txt
Uploading Purchase.txt to /data/web/90558/www/sap/Purchase.txt
sftp> bye
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2004 08:43 PM
12-06-2004 08:43 PM
Re: Cron job
Regards,
Fred
"Reality is just a point of view." (P. K. D.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2004 08:56 PM
12-06-2004 08:56 PM
Re: Cron job
I tried to use nohup, but again it was running well when run it manually, but not using cron. Contect of /tmp/sftp is exactly the same.
[root@prod:/opt/sapapp/L6A/SC/scripts/transfer]
# crontab -l|grep sftp
54 4 * * * nohup /opt/sapapp/L6A/SC/scripts/transfer/run_sftp > /tmp/sftp 2>&1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2004 09:03 PM
12-06-2004 09:03 PM
Re: Cron job
add this line :
. $HOME/.profile
Regards,
Fred
"Reality is just a point of view." (P. K. D.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2004 09:04 PM
12-06-2004 09:04 PM
Re: Cron job
sorry i forgot to ask you.
you are having cron.allow or cron.deny files in your /var/adm/cron directory.if existing the cron.allow file should contain the user name by which you are running sftp and the cron.deny file should not.(cron.allow with some user name s will allow only that users to run the cron.)
note:if cron.allow is there root entry should be must on that file.
regds,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2004 10:57 PM
12-06-2004 10:57 PM
Re: Cron job
If there is any interaction in the .profile, I would suggest you take a copy into a profile.con file and remove the interaction(s).
Regards
Jean-Luc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2005 04:36 AM
01-05-2005 04:36 AM
Re: Cron job
My suggestion is, search for sftp in your machine/server (Eg./usr/local/bin/sftp).
In your script add this path to the PATH variable. Make sure that sftp path is available to your cronjob script. Hope this works fine.
thanks
Allada