cwebp does not run as a cron job

90 views
Skip to first unread message

ahmadtr...@gmail.com

unread,
Jan 9, 2016, 10:58:34 AM1/9/16
to WebP Discussion
 I have a bash script that checks a directory and if there is no webp file for each jpg or png file, creates it using cwebp. this script runs perfectly when I call it manually, however when I schedule a cron job to, for example, run it every minute, cwebp does nothing. other commands in my bash script run without a problem, like rm. so I know this is not a permission issue. can anyone help me? what am I missing? I'm using Ubuntu 14.04.
here is my script:

#!/bin/bash




uploadDir
=/home/behnood/webptest/*


for file in $uploadDir
do
   
    if [[ $file = *.jpg || $file = *.png ]]
    then
        if ! [[ -f "$file".webp ]]
        then
           # there is no .webp file for this .jpg file, let's create it!
            cwebp "$file" -o "$file".webp
   
        fi
    elif [[ $file = *.webp ]]
    then
        if ! [[ -f "${file%.*}" ]]
        then
            #we have a .webp file but the original .jpg file is missing. let's delete it!
            rm "$file"
        fi
    fi
done


Pascal Massimino

unread,
Jan 9, 2016, 11:38:58 AM1/9/16
to WebP Discussion
Hi,

On Sat, Jan 9, 2016 at 12:41 AM, <ahmadtr...@gmail.com> wrote:
 I have a bash script that checks a directory and if there is no webp file for each jpg or png file, creates it using cwebp. this script runs perfectly when I call it manually, however when I schedule a cron job to, for example, run it every minute, cwebp does nothing. other commands in my bash script run without a problem, like rm. so I know this is not a permission issue. can anyone help me? what am I missing? I'm using Ubuntu 14.04.
here is my script:

#!/bin/bash




uploadDir
=/home/behnood/webptest/*


for file in $uploadDir
do
   
    if [[ $file = *.jpg || $file = *.png ]]
    then
        if ! [[ -f "$file".webp ]]
        then
           # there is no .webp file for this .jpg file, let's create it!
            cwebp "$file" -o "$file".webp

maybe it's because your script can't access 'cwebp' or doesn't know where to find it when in the 'cron' context.
Did you check your $PATH variable to make sure it can reach 'cwebp'. Or tried, for the sake of experiment, to copy
'cwebp' into /usr/bin and see if that's the right diagnostic?

hope it helps,
skal/
 
   
        fi
    elif [[ $file = *.webp ]]
    then
        if ! [[ -f "${file%.*}" ]]
        then
            #we have a .webp file but the original .jpg file is missing. let's delete it!
            rm "$file"
        fi
    fi
done


--
You received this message because you are subscribed to the Google Groups "WebP Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webp-discuss...@webmproject.org.
To post to this group, send email to webp-d...@webmproject.org.
Visit this group at https://groups.google.com/a/webmproject.org/group/webp-discuss/.
For more options, visit https://groups.google.com/a/webmproject.org/d/optout.

Reply all
Reply to author
Forward
0 new messages