Secret for copying files using CRON?

Bryan

Very Happy KH VPS User
Hey guys,

I'm trying to use CRON to copy a single file from one directory to another. It doesn't work when I use CRON, but works just fine from the command line.

ex. cp /home/user/directory/file.gif /home/user/public_html

Anybody have any idea what you need to do?
 
Hello Bryan,

You should be able to run that command just fine so far as I know. What is the error you receive? Anything in your cron or messages logs in /var/log?

Is the folder you're copying from/to in the same user's home folder?
 
Hey guys,

I'm trying to use CRON to copy a single file from one directory to another. It doesn't work when I use CRON, but works just fine from the command line.

ex. cp /home/user/directory/file.gif /home/user/public_html

Anybody have any idea what you need to do?

Have you tried turning the command into a script and then running the script from cron?

Is the cron running (ie: receiving email notification that it ran?)
 
Hi guys,

Dan, yes, the folder is in the same user's home directory. At work right now, so I don't have access to /var/log. Will check as soon as I get home.

Pmcwebs, now that I think about it, no. Never received any e-mail from that one. As far as I know, the other crons are working fine on that account, but I'm not 100% sure on that.
 
Hi guys,

Dan, yes, the folder is in the same user's home directory. At work right now, so I don't have access to /var/log. Will check as soon as I get home.

Pmcwebs, now that I think about it, no. Never received any e-mail from that one. As far as I know, the other crons are working fine on that account, but I'm not 100% sure on that.

So you're trying to run it as a user? What if you added it as root to crontab? If it set up as a user, is it copying from user directory to user otherdirectory, or is it copying from user1 to user2?
 
Hi again, pmcwebs. Thanks for the help.

Yep, it's copying from userdirectory to otheruserdirectory, not from one user to another.

Kinda weird that it won't run. I'll try running it from root as soon as I get home, instead of as the user. We'll see if that works.
 
Users can set up and run their own cron jobs so that shouldn't be the problem.

From what I've seen if it runs from the command line it should run in a cron job with no problem.

Only other thing I can think is the scheduling. Can you show us the exact line from the crontab?
 
Can you show us the exact line from the crontab?

Not sure what exactly you want to see.

cp /home/user/directory/file.gif /home/user/public_html

is the command being used (with directory names changed, obviously), and it's set in cPanel's CRON Manager to run whenever. I've changed it to run every minute to test, and still nothing.
 
Top