You are not logged in.
Pages: 1
I want to set up a cron job that will copy (update) my download folder that contains all my linux related stuff to the linux downloads folder contained in my windows downloads folder. I know how to set up crontab but vi(m) confuses me since it opens crontab as a temp file and I dont know what to call it when I try and save it. I tried using EDITOR=nano crontab -e but it still opens vim
heres the line I want to input into crontab:
0 3 * * * cp -Ru /home/bran/downloads/* "/media/mybook/Downloads/Linux Downloads/"
Last edited by brando56894 (2009-05-05 23:12:05)
Offline
Good afternoon brando56894,
You can use this command
export VISUAL=nano
Next time you will type crontab -e it will open nano.
Regards,
Last edited by phil90 (2009-05-04 20:58:55)
Offline
$ nano foo.cron
-- type whatever in your sweet editor --
$ crontab foo.cron
you could also learn vim, it's not hard (press 'i' to insert text then escape and type ':wq' to write and quit the file)
this guide is good (for cron, not vim):
http://www.scrounge.org/linux/cron.html
also can i recommend:
0 3 * * * cp -Ru /home/bran/downloads/* /media/mybook/Downloads/Linux\ Downloads/
Last edited by brisbin33 (2009-05-04 21:05:24)
//github/
Offline
... vi(m) confuses me since it opens crontab as a temp file and I dont know what to call it when I try and save it.
That's normal -- it's not vi(m), it's crontab. It copies to a temp file, you edit the temp file and then crontab does sanity checking on the file before moving it to the correct location.
This way if you completely fsck it, it will detect it, alert you, and then if you choose to cancel what you did, it just doesn't move the temp file over what was there before.
Last edited by fukawi2 (2009-05-04 22:20:43)
Are you familiar with our Forum Rules, and How To Ask Questions The Smart Way?
BlueHackers // fscanary // resticctl
Offline
thanks for the info everyone
$ nano foo.cron
-- type whatever in your sweet editor --
$ crontab foo.cronyou could also learn vim, it's not hard (press 'i' to insert text then escape and type ':wq' to write and quit the file)
also can i recommend:
0 3 * * * cp -Ru /home/bran/downloads/* /media/mybook/Downloads/Linux\ Downloads/
some good info here, a) didnt know you could add jobs like that b) didnt know you could enter insert mode by just pressing 'i' i always did :startinsert which was pretty annoying and :save [filename] :quit c) whats the difference between "Linux Downloads" and Linux\ Downloads?
Offline
hey, that was my bad. i guess it's a preference that i incorrectly characterized as a best practice. too much bash scripting makes me aware of when things don't _need_ to be double quoted... doesn't mean they _shouldn't_ be double quoted.
getting into that habit of the down slash in front of spaces might come in handy though b/c you would know to also put it in front of symbols like $ and ? which wouldn't behave well inside double quotes. however, in your case, either way works just fine.
i'll trade that bit of bum advice for some good advice though: look into rsync, it works very similar to cp except it won't spend all that time/energy copying files that are already there. does my nightly backup (~205 GB) in less than 3 minutes.
oh, and don't forget to add [solved] if you get this all working.
//github/
Offline
you could also just cd to /etc/cron.d and then make a new file...for example...
cd /etc/cron.d
sudo nano download-transfer.cron
edit your file as you want, and quit.
I always found it easier to manage tasks like this in seperate .cron files, and keep anything system necessary in crontab -e... which is more or less nothing i wrote.
Hope this is just some more helpful info. as you can see there are a ton of different ways to do this in the end!
However, a big +1 for learning Vi...the basics arent really bad at all. Once you conceptually understand the modal theory - the basic commands are just a small stretch away.
if you need more help beyond what you can find on the web feel free to PM me or anything instead of cluttering this up...I'm not a pro but i can comfortably use Vi(m).
good luck!
Offline
I tried adding the job to /etc/cron.daily but that didnt seem to have any effect on anything, ive been learning vim on and off for awhile now but its alot to learn and its completely different than anything else. I know the basic stuff (save, quit, quit!, startinsert) but thats about it. I think the best feature I love about it is the syntax highlighting since i usually use nano and it doesnt seem to work even when i tried to enable it in the config file.
hey, that was my bad. i guess it's a preference that i incorrectly characterized as a best practice. too much bash scripting makes me aware of when things don't _need_ to be double quoted... doesn't mean they _shouldn't_ be double quoted.
getting into that habit of the down slash in front of spaces might come in handy though b/c you would know to also put it in front of symbols like $ and ? which wouldn't behave well inside double quotes. however, in your case, either way works just fine.
i'll trade that bit of bum advice for some good advice though: look into rsync, it works very similar to cp except it won't spend all that time/energy copying files that are already there. does my nightly backup (~205 GB) in less than 3 minutes.
oh, and don't forget to add [solved] if you get this all working.
haha its cool, i was actually thinking about using rsync originally but then i was looking up a guide for it and it seemed to complex to do something simple like I needed to do. my linux downloads folder is only about 400 or so mb and the u flag updates only changed files so it doesnt take that long anyway.
Offline
rsync -av --delete /home/source /mnt/dest
Are you familiar with our Forum Rules, and How To Ask Questions The Smart Way?
BlueHackers // fscanary // resticctl
Offline
brando56894 wrote:... vi(m) confuses me since it opens crontab as a temp file and I dont know what to call it when I try and save it.
That's normal -- it's not vi(m), it's crontab. It copies to a temp file, you edit the temp file and then crontab does sanity checking on the file before moving it to the correct location.
This way if you completely fsck it, it will detect it, alert you, and then if you choose to cancel what you did, it just doesn't move the temp file over what was there before.
There's no sanity checking---at least not in dcron. It's not like visudo. All that dcron's crontab does is make sure the temp file gets copied to the right place, with the right metadata, and that a cron.update file gets generated so that a running crond will notice the updated file within the next minute. (crond also does a full rescan of its crontab directories once an hour, even without the cron.update file.)
Offline
I thought it did a basic column count to make sure the first 5 (min, hour, dom, month, dow) were valid, and then there was 'something' (ie a command) after it?
Are you familiar with our Forum Rules, and How To Ask Questions The Smart Way?
BlueHackers // fscanary // resticctl
Offline
dcron doesn't do this. I'm freshly acquainted with the source because I've just forked it. But vixiecron might do that.
Offline
Pages: 1