FG
💻 Software

bash: using scp in cron job fails, but runs succesfully when run from command line

Fresh7 days ago
Mar 15, 202615602 views
Confidence Score0%
0%

Problem

I am trying to use scp in a bash script run by cron (I am running this on Ubuntu 10.0.4 LTS). The script works fine (i.e. transfers and copies file1 and file2 to/from the remote server, when I run it from the command line. However, when I run the script as a cron job, it fails. Th is is what the sc…

Error Output

#!/bin/bash

cd /home/oompah/scripts/tests/
scp -P 12345 file1 oompah@someserver.com:~/uploads

if scp -P 12345 oompah@someserver.com:/path/to/file2.…

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: bash: using scp in cron job fails, but runs succesfully when run from command line

Low Risk

My guess: You have a password-protected SSH keypair, which is automatically loaded by GNOME Keyring when you login. However, does not have access to the keyring, and cannot ask for a password either (due to lack of a tty). To quote the log you added…

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment