How to setup a cron job in Cpanel to move a file to another directory on the server and rename it

StackOverflow https://stackoverflow.com/questions/22413350

  •  14-06-2023
  •  | 
  •  

Frage

I have a server backup .tar.gz file that I need to automate it's move to another folder, and rename it to a name I can use to later download it via ftp (I can't use wildcard to download the file so I have to know the name in order to grab it). I have the other pieces straighten out, I just need to know how/what my cron job script should look like. Can I do this via PHP? or do I need something else? Thanks in advance for the help

War es hilfreich?

Lösung

To answer my own question with some help from @ssaltman above, I did it in PHP and used the following code:

<?php
rename(reset(glob("/exist/path/*.tar.gz")), "/new/path/NEWNAME.tar.gz");
?>

I then attached it to a cron job in cpanel.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top