Cronjob for overwriting file in a special user folder not functioning

alwaysbusy

Verified User
Joined
Apr 19, 2020
Messages
108
Hi

following situation:
I have a DirectAdmin server with several users (+ domains) on it. This are all domains from me, so there are in real no other users using that server beside me.

I have a json database file, which needs to get updated every few minutes for a script. And i need it on several domains. Before now every users is downloading the json file via a cronjob every few minutes and generating there a traffic volume from a few tb per month, i thought i download it on one place and make then a cronjob, which is overwriting this json database file in the necessary user folders.

My technical guys from the server setup for this the following cronjob as admin:
cp -rf /home/usera/public_html/cronjobs/foldera/database.json /home/userb/public_html/folderxyz/database.json -y

For example: the cronjob should copy from "usera" from the folder "foldera" the file "database.json" to "userb" in the folder "folderxyz" and overwrite there the "database.json" file every 5 minutes. But this command seems not to work and my technicals guys are trying to fix this already since hours.

Has someone a tip for me, how i can get this working in an easy way?

Thanks and Greets
 
cronjob will run as user,
so that why you can't copy file between user with Cronjob like that
Also "admin" is a member too, it's can't access to other User Home too,

You can trying to run command directly without cronjob and see result


So I think you should run with root and do chown after finish copy

or you need set permission on userfile "/home/userb/public_html/folderxyz/"
with something like "chown userb:usera"
so this is bad idea i dont recommend it.
 
Hi,

thanks for your answer and help.

Can i also run a command automatically every x minutes for example?

Or is there on DirectAdmin a other possibility that i can share as admin a file with several users on my own server?

Greets
 
If someone else needs it:
My technicians had been adding the cron under roe root crontab, so they can copy from user a a file to user b in a given time interval and overwrite there a specified file. Its functioning.

Greets
 
Back
Top