Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Cron jobs and scripts

Posted on 1998-11-22
5
Medium Priority
?
230 Views
Last Modified: 2013-12-27
I got a script that is usse to purge web server log
files and I place it in /usr/fs-home/scripts/purge_Log.script

1. Is that the correct place to put a cron job script?
any best practisces or recommended place
2. How do I add this to the crontab so that it will run on
every Monday 6am?

I'm using Sun 2.5.1
Pls. advise.
0
Comment
Question by:slok
  • 2
  • 2
5 Comments
 
LVL 85

Expert Comment

by:ozo
ID: 2007987
0 18 * * 1 /usr/fs-home/scripts/purge_Log.script
0
 
LVL 85

Expert Comment

by:ozo
ID: 2007988
#oops, I thought you said 6pm
0
 
LVL 4

Accepted Solution

by:
davidmwilliams earned 100 total points
ID: 2007989
1/ There is really no 'correct place' to put a cron job script - what is usually good is to place it in a directory with other scripts, or perhaps in an 'etc' directory near the file area that is functionally related to what the cron job deals with.  So, in your case, maybe somewhere near the Web server area.
The 'fs-home' directory looks non-standard, so it may be a directory made by your Web server, or perhaps your company - either of which would be good reasons to put the script there.

2/ Use 'crontab -e' to edit a crontab.  You need to make sure you do this as root -- or as an appropriate user, because in Solaris 2.5 any user can have their own crontab, as opposed to systems that have just one crontab.
Then, add the line that Ozo suggested above, but change the 18 to 6.
0
 
LVL 3

Author Comment

by:slok
ID: 2007990
when I do a crontab -e,
am I editing the existing cron file ?

last when I try crontab -e, it put me into some kind of editor without
any content (the existing cron jobs) ?

Do I just type that line in after I type crontab -e ?
0
 
LVL 4

Expert Comment

by:davidmwilliams
ID: 2007991
 crontab -e  will edit the existing crontab for _you_ ... that is, the crontab associated with your current login.
  If it is coming up empty, then the crontab for that login is empty - which is likely to be the case if you are logged in as yourself.
  If you type  ls -l /var/spool/cron/crontabs  you should be able to see all the existing crontabs.  To edit the crontab for another user, either login as that user, or use the  su  command to 'become' that user -- then do the  crontab -e  again.
  The editor that is used is controlled by the EDITOR environment variable - so you can set this to any editor you like, such as vi or emacs or pico or even an X-Window based editor.
  When you are sure you are editing the appropriate crontab file, then yes, you just add the above line in, to the file, on a line by itself.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Suggested Courses

877 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question