February 13th, 2012, 07:04 PM
Replicating a crontab from one UNIX system to another one
What is the most efficient and easy way to create a crontab from another one, on a UNIX platform (no Windows machines involved)?
I want to replicate an existing crontab from a test system and copy it over to the development system.
I am using "crontab -e" on both systems in a vi environment. Currently I am copying and pasting one line at a time, minus the last character of the line and typing that. If the line is so long that it wraps around to another line, then I am typing the last bit of the line and the first bit of the next line, then copying and pasting the rest of the line minus the last character and typing that.
Why, you might ask? Well, I seem to get syntax errors otherwise and I do not know if I have any kind of debugging tool. However, this is not a short file.
I get a syntax error trying to copy and paste within the test file itself, so it's not a question of the difference between the systems, just simply when trying to save the file. My UNIX book did not even mention using ZZ to save the file. I do have access to Safari Online at work.
February 14th, 2012, 03:54 AM
So you just need to copy the file? Try something like SCP. Worst case, grab a USB drive and manually copy the file that way.
February 14th, 2012, 08:19 AM
What is SCP? I do not even know where the file is located. I use the "crontab -e" command and there it is. I use :w! then the filename I used for a backup of the information to write the information to a file for safekeeping.
Originally Posted by requinix
Someone mentioned looking at /var/cron, so I will try looking there.
Also, someone mentioned the following command to edit out what may be the problem with line feed characters:
They called the caret the control key at one point and an escape character at another point. I believe they meant to literally type the above command. However, I saw no ^M at the end of the lines after copying and pasting.
February 14th, 2012, 09:18 AM
- I don't know what ^V is, but ^M is a line ending character. If you were seeing it then that would mean the file has Windows-style line endings (which would be weird for the crontab file).
- crontab -e edits the crontab file. It's generally in /etc but could be somewhere else. That's what you'd want to copy. Your distro might have other crontab locations, like /etc/cron.daily or cron.monthly; you might want those too.
- SCP lets you copy files across systems when you have SSH access to both. Google it.
February 14th, 2012, 02:40 PM
I do not see any ^V or ^M when using "crontab -e".
I can look in those locations for the saved file.
February 15th, 2012, 09:35 AM
There is alos the option of using crontab -l to list the cronfile, and redirecting the output to a file which you could copy across if you are not sure where the cronfiles exits. A man crontab should tell you the location of the files.
The moon on the one hand, the dawn on the other:
The moon is my sister, the dawn is my brother.
The moon on my left and the dawn on my right.
My brother, good morning: my sister, good night.
-- Hilaire Belloc
February 15th, 2012, 09:45 AM
Follow SimonJM instructions:
crontab -l >cron.txt
scp cron.txt otherHost:/`pwd`
## login to otherHost
crontab -e <cron.txt