开发者

why cygwin cron cannot find a file when cygwin ls can?

开发者 https://www.devze.com 2023-01-02 21:10 出处:网络
I got a cron job scheduled by using cygrunsrv and vixie\'s cron for cygwin. The job is a shell script that copies files from one directory to another and renames them.

I got a cron job scheduled by using cygrunsrv and vixie's cron for cygwin. The job is a shell script that copies files from one directory to another and renames them.

The script is in /home/martin/my/script/copy_files.sh. And the permission for the path is:

drwxrwxrwt+ 1 martin root         0 2010-06-02 17:36 home
drwxr-xr-x+ 1 martin Domain Users 0 2010-06-03 16:19 martin
drwxrwxrwt+ 1 martin Domain Users 0 2010-06-02 16:47 my
drwxrwxrwt+ 1 martin Domain Users 0 2010-06-04 16:31 script
-rwxr-xr-x  1 martin Domain Users 439 2010-06-02 18:10 copy_files.sh

When I ls -l, the source file is:

-rwxrw-rw-  1 martin Domain Users 13856 2010-06-04 10:05 .bash_history

But when the job runs, the cp command failed due to

cp: /home/martin/.bash_history: The system cannot find the path specified.
开发者_如何学Go

So what is wrong? How can I fix it?

Thank you.


I have not looked at cygwin for a few so my details in this are going to be few.

Your problem is the directory tree. You need to set the cwd (use cd) to /home/martin before you copy. The trick is knowing where /home is located, relative to the place where cron logs in. I frankly don't remember, but I do remember that I could not find it in the docset.

Let's assume the time is 15:28. go into crontab -e add this:

30 * * * *  /usr/bin/echo "current dir= $(pwd)  $PATH" 2&>1 > ./19191919.log

wait until 15:31, go into crontab -e and remove that entry. We dont' want it anymore

find / -type f -name 19191919.log  -exec /usr/bin/cat {} \;

This will tell you what you need to know. about both the PATH and where login directory turns out to be. My experience with vixie was that it WAS NOT the home directory in /etc/passwd

There was some .conf file that overrode /etc/passwd.

This was long ago, so sorry if things turn out different.

0

精彩评论

暂无评论...
验证码 换一张
取 消