• Hi, Pleskians! We are running a UX testing of our upcoming product intended for server management and monitoring.
    We would like to invite you to have a call with us and have some fun checking our prototype. The agenda is pretty simple - we bring new design and some scenarios that you need to walk through and succeed. We will be watching and taking insights for further development of the design.
    If you would like to participate, please use this link to book a meeting. We will sent the link to the clickable prototype at the meeting.
  • (Plesk for Windows):
    MySQL Connector/ODBC 3.51, 5.1, and 5.3 are no longer shipped with Plesk because they have reached end of life. MariaDB Connector/ODBC 64-bit 3.2.4 is now used instead.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.

Question Cron job to rename image files - syntax question

onki

Regular Pleskian
Server operating system version
ubuntu 20.04
Plesk version and microupdate number
18.0.59
I am using a IP camer that uploads an image in a time sequence (currently once ever 15 minutes).
The current camera uploads the images with time coded file name (e.g. Schedule_20240430-213000.jpg).
the new camera always uses the same filename (schedule.jpg) and I cannot change that.
Since I want to display the last 4 images on my website I need to change the file name to a timecoded in a cron job.
Is this possible by using a cron command or do I need a shell script?
Any help is welcome since I am struggeling with the syntax.

I created a shell script and tried to run it through the cron command:
sh /usr/local/sbin/rename_cam.sh
But this does not work. script is executable (755)

This is the script:
#!/bin/bash

if [[ -f "var/www/vhosts/mydomain.de/httpdocs/images/webcam/ip_cam_le202/Snapshot/snapshot.jpg" ]]; then
mv /var/www/vhosts/mydomain.de/httpdocs/images/webcam/ip_cam_le202/Snapshot/snapshot.jpg /var/www/vhosts/mydomain.de/httpdocs/images/webcam/ip_cam_le202/Snapshot/$(date +%y%m%d%H%M%S).jpg
fi
When I try to run the script I get this error:
/usr/local/sbin/rename_cam.sh: 3: [[: not found

What could be the problem?

Best regards
Onki
 
Now the message is gone when I use bash command. But my file is still not renamed.
Is there anything wrong with my script?
 
Thanks, that was one of the problems that I found. All were path related.
Thanks for solving the issue.

br
Onki
 
Back
Top