Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cron - gsutil not found

Tags:

shell

cron

gsutil

gsutil has been installed here:

/usr/local/bin/gsutil

My crontab looks like this (i'm logged in as root):

 */1  *  *  *  * /home/deploy/cron/job.sh >> /home/deploy/cron/test.log 2>&1

job.sh:

#!/bin/sh
PATH="$PATH":/usr/local/bin/gsutil
now=$(date +"%m_%d_%y_%R");
cp /home/deploy/testfile.txt /tmp/testfile_$now.txt;
gsutil cp /home/deploy/testfile.txt gs://testbucket/testfile_$now.txt;

echo "saved file at $now";

When I look in my log file I see this:

/home/deploy/cron/job.sh: 5: /home/deploy/cron/job.sh: gsutil: not found
saved file at 07_20_15_13:03

Any idea what I'm doing wrong?

like image 947
Justin Young Avatar asked Jul 20 '15 17:07

Justin Young


2 Answers

Had the same issue, you need to specify the full path when you call gsutil. In your case:

/usr/local/bin/gsutil/gsutil cp /home/deploy/testfile.txt gs://testbucket/testfile_$now.txt;
like image 92
Alberto C Avatar answered Oct 30 '22 15:10

Alberto C


yes, you have use the full path gsutil command to use in crontab

/root/gcloud/gsutil cp ...

like image 41
Aldom Michael Avatar answered Oct 30 '22 14:10

Aldom Michael