cd and cron?
Can someone explain to me why "cd" doesn't work in cron? I want to manipulate some files in a cron job, and I don't want to have to spell out the whole file address each time in my command line. I tried "PATH=workingdirectory; commandline", and that doesn't seem to work either.
-
Try to use /usr/bin/cd instead of cd 0 -
Try to use /usr/bin/cd instead of cd
Nope. That doesn't work at all. That is, /usr/bin/cd ; cat x y > z doesn't work, but cat /home1/memyselfandi/mydirectory/x /home1/memyselfandi/mydirectory/y > /home1/memyselfandi/mydirectory/z does work Pretty annoying.0 -
Can you let us know specifically what you're trying to do? I'm not sure that cron has an idea of a current directory, as it just reads the path you provide, so knowing more about what you're trying to do might help us provide a workaround. 0 -
Well, I gave an example of what I'm trying to do. I want to put such a functionality in my cron command set. I want to schedule that functionality using cron. 0 -
Does your command work on the command line outside of cron? I don't see where your "cd" command actually changes into a directory. 0 -
If you really wanted to use "cd" you could create a bash script file and have cron call that, and I would expect that to work well. 0 -
Yes, my command line works perfectly outside of cron. I guess I could call a script, but we're talking about just a short command line. Odd that cron can't handle it. Oops, good point. I meant /usr/bin/cd /home1/memyselfandi/mydirectory; cat x y > z doesn't work, 0 -
Points noted. Thank you. But you'd think all this would be spelled out in cron documentation. Also interesting that PATH delimiter doesn't seem to work in the cron instruction. As in PATH memyselfandi/mydirectory; cat x y > z 0 -
I think you are mixing PATH and HOME variables :rolleyes: 0
Please sign in to leave a comment.
Comments
10 comments