0

I am looking for a specific command/script for a cron job I want to perform.

Basically, I have a WordPress website that when you fill in a form writes a png file to a folder. usually with a name like 5d5bb3f4cdcad3.49988477.png.

Basically what I want to do is when a new file is detected in the folder ftp that file to an ftp server. Or preferably email the file, the server does run cPanel so I actually don't know if there is a command function for emailing.

I am used to working with powershell so linux is not my mother-tongue.

3
  • What have you already tried? Please show us what your research got you – I'm sure there are some answers around for syncing directories via FTP under Linux.
    – slhck
    Aug 20, 2019 at 10:51
  • I have found inotifywait as a tool to use with linux. My problem is that on the server I don't think I have permissions to install software. superuser.com/questions/956311/… Aug 20, 2019 at 10:58
  • That makes everything much more complicated of course. Is it a shared web server space that you've rented? Perhaps you could explain a little bit more about the environment and what you've already tried. Do you have an ftp command available (e.g. lftp)? See askubuntu.com/a/758651/17529
    – slhck
    Aug 20, 2019 at 11:18

2 Answers 2

0

In your case, I don't think cron on its own is going to be useful for you.

You might want to look at a tool called rsync. It can be set up to look for new files in a location and then move these. You can even move the files across ssh to another server using

rsync -v --ignore-existing -e ssh /home/localuser/ [email protected]:/home

I would then schedule a cron job to run every minute/5 minutes to call this function to copy the files where you need.

For more information on rsync, you can use the man rsync command on linux, but there are lots of great tutorials online for rsync which might be easier to get to grips with.

1
  • I guess your example would be better if it didn't point to a file but a source directory. Also, rsync does not support FTP, so it's not a solution for the OP's issue.
    – slhck
    Aug 20, 2019 at 10:51
0

Although I didn't find a direct solution to my problem I found an alternative.

My problem was when the files where being written it was generating a link that would send via email and the link wasn't being called in PHP properly and you couldn't display the file in your web browser. That is why I needed to send it through ftp or email the file.

I found an alternative, I was using a form plugin and it was generating signature image files, I found a function of the plugin to generate a PDF file with all the details and it works properly.

Case closed I guess lol.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .