Crontab question


 
Thread Tools Search this Thread
Operating Systems HP-UX Crontab question
# 8  
Old 07-03-2009
crontab -e by default uses vi. The point here is avoiding corrupting or deleting content in an important file like /etc/crontab just because you want to look at it. Obviously vi works. crontab -l is safe. view is safe. vi is not a safe tool to piddle around with the /etc/crontab file.

Safe habits include using crontab, not vi.
# 9  
Old 07-03-2009
I agree with Jim, that using -e just to view can be unsafe... I always vi a freshly generated file... or crontab -l|more ...( some of our DBAs used to till they lost their file and realised they had no spare...It so easy to not know what you are doing with people entering in your office and distract you while the phone starts ringing...)
# 10  
Old 07-06-2009
I agree with vbe. I copy the crontab twice (both with and without a date suffix) to backed-up workspace. Edit with vi and then publish the crontab with "crontab <filename>". This means you have a safe copy of the current crontab, and a copy of all previous crontabs. If you want to check your changes you can run "diff".
# 11  
Old 09-15-2009
Hi, a new question about crontab.
I have some machine in cluster to avoid interuption in manufacturing process. When one is alive the other one is sleep.
Some time happens to switch between them. So i stop the crontab in one and start it in other one. The question is how can i ensure that the two cron are the same? I made a shell to check the difference in the two /var/spool/cron/crontabs directory and it work fine. When an alarm arrive i manualy align the user crontab file in the sleeping machine using crontab -e. My boss ask to me to do this action automaticaly. Do u think that is correct to align the crontab using the remote copy of the users crontab file? I'm not sure, for instance if i make the user crontab using the vi the shell doesn't start. For the same reason i prefer align the crontab manualy beaside with a shell that make a rcp. That's is correct or do u think that i could be use the rcp between the /var/spool/cron/crontabs files?

Best Regards,
Andrea.
# 12  
Old 09-16-2009
Ive seen people spend weeks building up a (redoutable...) cron file after it was lost after a crash and needed to reinstall to OS ( for many sites DONT backup /var in root vg (vg00) eg /var/opt here is another file system as is /var/opt/oracle also and are backed up...)
if you had a copy of you cronfile elsewhere (home directory of that cron user or dedicated directory e.g. /sm/cron) you would always use vi to edit/save followed by a crontab cronfile, you could then compare the file with what is in /var/spool and also rdist it to the other box without using crontab -e, starting the alternate box would be to do just the same with the difference of a first crontab cronfile Im sure it could be automated if needed
# 13  
Old 09-16-2009
This is a timely topic for me. I was looking into just such a problem since I have a two node Service Guard cluster, in use. We have an applications volume group active on only one server at a time. Depending upon which server it is active on, the crontab file has extra jobs to run.

So I thought of having a dedicated and separate area for the local crontab file, and one on the application volume group for the crontab file specific to it.

Then a script could be made to merge the local cron job file with the cron file from the application volume group (if it's mounted) and then submit the merged crontab file to cron. This script would run with the startup of the cluster package for the application volume group.

The local crontab file would look something like this

Code:
 
#<header info>
# LOCAL start
<cron job>
<another cron job>
<etc>
# LOCAL end

And the app volume group crontab file

Code:
 
# APP start
<cron job>
<another cron job>
<etc>
# APP end

A script could easily cat those two files, together into a new crontab file keeping the application specific information last in the file. The process can be "reversed" by resubmitting just the local file when the app volume group is switched back to its primary node. If changes were made in the meantime, to the local portion, no problem, as a simple:

Code:
 
crontab -l | sed -n -e '1,/\# LOCAL end/ p' > newlocal.cron

should give me the most current local listing that can be submitted to eliminate the application volume group entries (of course the changes should have been made to a separate file first, and then submitted so I already have a record of them).

I haven't put this together, yet, it's just been rattling around in my brain at this point, but that's the gist of it. Seems so easy, I must be missing something! Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Question on crontab

Hello, I have scheduled the execution of a file (delete_oldv02) every hour with crontab and it works perfectly. See below the instruction written. 0 */1 * * * /home/delete_oldv02 >>/home/delete_oldv02.log My first question is if I can add one more line to crontab. I also would like to... (5 Replies)
Discussion started by: dcaccount
5 Replies

2. Shell Programming and Scripting

Crontab question

I need to run an script every 10th and 25th day in every month at 11pm. the script name is /home/ss/automated.sh I tried to execute the script every day and everytime with the below syntax. its not executing it from crontab. * * * * * /home/ss/automated.sh Any idea why it not... (6 Replies)
Discussion started by: ramkumar15
6 Replies

3. UNIX for Dummies Questions & Answers

Another crontab question

Hey out there This is all I have in my crontab file. I know the crontab works because it was already out there and working. I simply replaced the existing with my line of code below to see if it worked. I uploaded 6 month old pdf files in this directory, stopped/started all the scripts that... (3 Replies)
Discussion started by: vsekvsek
3 Replies

4. Solaris

Crontab question

I want to run a script on (say) the 4th friday every month. But if I include this line in the crontab : 45 9 22-28 * 5 echo '4th Friday'|mailx -s "Fri week 4" mike it sends me mail if the date is 22-28, OR the day is friday. So I get mail every day for a week , and also every friday. I... (2 Replies)
Discussion started by: mikejordan
2 Replies

5. Shell Programming and Scripting

crontab question

I have a user (xxx) who is allowed to run cron jobs when a job is launched from cron is the .profile sourced in? I am not sure it is so I setup a cron job as this user to do the following: 35 15 * * 0-5 su - xxx -c "ksh ls -lt /tmp" > /tmp.out and I am seeing the following error (see... (2 Replies)
Discussion started by: BeefStu
2 Replies

6. UNIX for Dummies Questions & Answers

Question about crontab

Hello guys, I have a server with Red Hat Enterprise Linux AS release 4 (Nahant Update 5), there i have a lot of users, im the root. I need to lock the use of crontab to the users, i mean, i dont want to give to the users the option to creat any crontab line, how can i do that? I tried to... (4 Replies)
Discussion started by: lestat_ecuador
4 Replies

7. AIX

How-to crontab question

My question is how to specify the one-time execution of a shell script in crontab? For example: If I wanted to schedule shell "Test.sh" for one-time execution on December 13 at 8:00AM would it be as follows? 00 08 13 12 6 /usr/datatools/dtbackups/Test.sh > /usr/u/sybase_12.5/logs/Test.log &... (3 Replies)
Discussion started by: Alan.AIX
3 Replies

8. UNIX for Dummies Questions & Answers

Crontab Question.

I set up a job to run a script in a certain directory to remove certain files. The script seems to run as my logs indicate but nothing happens. If I run the script manually then it removes the correct files. I'm now wondering if crontab doesnt have access to remove files from the directory I'm... (9 Replies)
Discussion started by: NycUnxer
9 Replies

9. Solaris

Crontab question

HI all, I would want to schedule a job to run every 2 weeks. In the mean time, i'm only able to schedule on every week. Is it possible to schedule 2 weeks on crontab? Thank you. (3 Replies)
Discussion started by: *Jess*
3 Replies

10. UNIX for Dummies Questions & Answers

crontab question

Why does this cron entry do nothing? It works interactively. 58 23 * * * mydate=`date '+%Y%m%d'`;mv /opt/home/user/file /opt/home/user/file_$mydate (5 Replies)
Discussion started by: steelrose
5 Replies
Login or Register to Ask a Question