Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 2508

Raspberry Pi OS • Cron doesn't want to execute a shell script that works fine on its own

$
0
0
Hi all,

I'm trying to get cron to execute a shell script that takes a picture and uploads it to a Google Drive. I want this to happen every day at the same time, but right now I'm just testing to see if it'll do it every minute.

The shell script is called

Code:

newpicsync.sh
and contains the following:

Code:

#!/bin/bashdate=$(date +"%Y-%m-%d")extension="jpg"new_filename=${date}.${extension}destination_path=""/Pictures/testfolder"/${new_filename}"#Take a picture using libcamera, save it with a datename-based filenamerpicam-still -o $destination_path#Sync the picture to my Google drive with rclonerclone copy /Pictures/testfolder TestDrive:rpipics/Camera1echo $destination_path
When I execute this script on its own, it successfully boots up the camera, takes a photo, saves it to testfolder, and then uploades the photo to my Google Drive.

However when I wrap this in a crontab (saved as /tmp/crontab.62vCd5/crontab):

Code:

# Edit this file to introduce tasks to be run by cron.# ...# m h  dom mon dow   command* * * * * sh  /home/username/newpicsync.sh
Nothing happens. I get the message crontab: installing new crontab, but the script doesn't get executed.

Can anyone shed some light on what might be happening?

Statistics: Posted by phylojenie — Wed May 15, 2024 5:38 pm



Viewing all articles
Browse latest Browse all 2508

Trending Articles