Re: Cron script problem....
At 01:05 PM 12.11.2002 -0600, Eric Six wrote: Hi All, I am having a weird problem on a freebsd 4.7. I have two perl scripts I am running via cron, one is run as root to make a backup of a directory and the files in it, the second is run as a user to scp files to another box. What I am encountering is the second script is running but dying after the first ssh remote command. Here is what second script does; it uses ssh remote command to create a directory on the remote server with todays date, the next command is the actual recurise scp command. Here is what the script looks like; ~begin~ #!/usr/bin/perl -w # tar cf filename.tar pathtotar/ chomp ($SCP=`which scp`); chomp ($SSH=`which ssh`); $pathtomakebackup=/bind_backups; chomp ($today=`date`); my ($day,$month,$date,$time,$timezone,$year) = split (' ',$today); $archive_date=$month-$date-$year; `$SSH backupuser\@server13.blah.com mkdir ~/bind_backups/nsX/$archive_date /var/log/ssh.log 21`; `$SCP -vr $pathtomakebackup/$archive_date/ backupuser\@server13.blah.com:~/bind_backups/nsX/ /var/log/scp.log 21`; ~end~ If I run the script interactively, it works fine. From CRON it dies after the SSH command makes the directory on the remote server. Here is how I have it setup in cron; 05 22 * * 1,3,5 perl /adminscripts/erics/bind_backup_scp.pl It works fine from cron on Solaris and Linux... anyone have any ideas? TIA Eric Eric: I'm no script expert, but perhaps if you added the full path to perl in the cron line. That's usually a problem Best regards, Jack L. Stone, Administrator SageOne Net http://www.sage-one.net [EMAIL PROTECTED] To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-questions in the body of the message
Re: Cron script problem....
Jack L. Stone [EMAIL PROTECTED] writes: Hi! Eric: I'm no script expert, but perhaps if you added the full path to perl in the cron line. That's usually a problem Shouldn't be the case here, because then, the script wouldn't start at all, but as Eric has pointed out it runs up to the first SSH call. Eric, it might be a good idea to call ssh with the -v switch and capture the output of the command. Maybe it sheds some light into your problem. Do you use the same user for interactive and cronjob operation? norbert. To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-questions in the body of the message
RE: Cron script problem....
Interactively, I am running the script as the backup account that cron uses to run the copy script. And it runs correctly interactively. I try the ssh -v and see if that says anything.. Is there a timeout issue that cron might be seeing? Anyone know? hmm.. I am stumped. Eric -Original Message- From: Norbert Koch [mailto:[EMAIL PROTECTED]] Sent: Wednesday, December 11, 2002 1:50 PM To: Jack L. Stone Cc: Eric Six; '[EMAIL PROTECTED]' Subject: Re: Cron script problem Jack L. Stone [EMAIL PROTECTED] writes: Hi! Eric: I'm no script expert, but perhaps if you added the full path to perl in the cron line. That's usually a problem Shouldn't be the case here, because then, the script wouldn't start at all, but as Eric has pointed out it runs up to the first SSH call. Eric, it might be a good idea to call ssh with the -v switch and capture the output of the command. Maybe it sheds some light into your problem. Do you use the same user for interactive and cronjob operation? norbert. To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-questions in the body of the message
Re: Cron script problem....
On Wed, Dec 11, 2002 at 01:05:13PM -0600, Eric Six wrote: Hi All, I am having a weird problem on a freebsd 4.7. I have two perl scripts I am running via cron, one is run as root to make a backup of a directory and the files in it, the second is run as a user to scp files to another box. What I am encountering is the second script is running but dying after the first ssh remote command. Here is what second script does; it uses ssh remote command to create a directory on the remote server with todays date, the next command is the actual recurise scp command. Here is what the script looks like; ~begin~ #!/usr/bin/perl -w # tar cf filename.tar pathtotar/ chomp ($SCP=`which scp`); chomp ($SSH=`which ssh`); $pathtomakebackup=/bind_backups; chomp ($today=`date`); my ($day,$month,$date,$time,$timezone,$year) = split (' ',$today); $archive_date=$month-$date-$year; `$SSH backupuser\@server13.blah.com mkdir ~/bind_backups/nsX/$archive_date /var/log/ssh.log 21`; ^^^ Does the user have permission to write to this file? `$SCP -vr $pathtomakebackup/$archive_date/ backupuser\@server13.blah.com:~/bind_backups/nsX/ /var/log/scp.log 21`; ~end~ If I run the script interactively, it works fine. From CRON it dies after the SSH command makes the directory on the remote server. Here is how I have it setup in cron; 05 22 * * 1,3,5 perl /adminscripts/erics/bind_backup_scp.pl It works fine from cron on Solaris and Linux... anyone have any ideas? TIA Eric To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-questions in the body of the message -- Michael Galvez http://www.people.virginia.edu/~mrg8n Computer Systems Sr. Engineer Office: 434-982-2975 Financial AnalysisE-Mail: [EMAIL PROTECTED] University of VirginiaMessenger Mail: Carruthers Hall Toilet Toup'ee, n.: Any shag carpet that causes the lid to become top-heavy, thus creating endless annoyance to male users. -- Rich Hall, Sniglets To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-questions in the body of the message
Re: Cron script problem....
At 08:49 PM 12.11.2002 +0100, Norbert Koch wrote: Jack L. Stone [EMAIL PROTECTED] writes: Hi! Eric: I'm no script expert, but perhaps if you added the full path to perl in the cron line. That's usually a problem Shouldn't be the case here, because then, the script wouldn't start at all, but as Eric has pointed out it runs up to the first SSH call. Eric, Right, had my blinders on when I read his note Best regards, Jack L. Stone, Administrator SageOne Net http://www.sage-one.net [EMAIL PROTECTED] To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-questions in the body of the message
RE: Cron script problem....
I've added the verbose flag to ssh. Here is snipet from the log.. The connection is built, directory made, and connection torn down. It seems as if ssh is sending a kill or exit after it runs?? debug1: Reading configuration data /etc/ssh/ssh_config^M debug1: Applying options for *^M debug1: Rhosts Authentication disabled, originating port will not be trusted.^M debug1: restore_uid^M debug1: ssh-userauth2 successful: method publickey^M debug1: Entering interactive session.^M debug1: client_init id 0 arg 0^M debug1: Sending command: mkdir /bind_backups/ns3/Dec-11-2002^M debug1: client_input_channel_req: channel 0 rtype exit-status reply 0^M debug1: channel 0: rcvd close^M debug1: channel 0: is dead^M debug1: channel_free: channel 0: status: The following connections are open:^M #0 client-session (t4 r0 i8/0 o128/0 fd -1/-1)^M ^M debug1: channel_free: channel 0: dettaching channel user^M That's the last line of the log.. nothing else is run. SCP should be invoked from there... Eric -Original Message- From: Eric Six [mailto:[EMAIL PROTECTED]] Sent: Wednesday, December 11, 2002 1:53 PM To: 'Norbert Koch' Cc: '[EMAIL PROTECTED]' Subject: RE: Cron script problem Interactively, I am running the script as the backup account that cron uses to run the copy script. And it runs correctly interactively. I try the ssh -v and see if that says anything.. Is there a timeout issue that cron might be seeing? Anyone know? hmm.. I am stumped. Eric -Original Message- From: Norbert Koch [mailto:[EMAIL PROTECTED]] Sent: Wednesday, December 11, 2002 1:50 PM To: Jack L. Stone Cc: Eric Six; '[EMAIL PROTECTED]' Subject: Re: Cron script problem Jack L. Stone [EMAIL PROTECTED] writes: Hi! Eric: I'm no script expert, but perhaps if you added the full path to perl in the cron line. That's usually a problem Shouldn't be the case here, because then, the script wouldn't start at all, but as Eric has pointed out it runs up to the first SSH call. Eric, it might be a good idea to call ssh with the -v switch and capture the output of the command. Maybe it sheds some light into your problem. Do you use the same user for interactive and cronjob operation? norbert. To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-questions in the body of the message To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-questions in the body of the message
Re: Cron script problem....
Eric Six [EMAIL PROTECTED] writes: That's the last line of the log.. nothing else is run. SCP should be invoked from there... Hmm, everything looks fine. You don't need a return value, so you could try and issue the command as system($SSH, @args) and examine the return code. But this is short of a wild goose chase :-/ norbert. To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-questions in the body of the message