Cron jobs and scripts

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.
LVL 3
slokAsked:
Who is Participating?
 
davidmwilliamsConnect With a Mentor Commented:
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
 
ozoCommented:
0 18 * * 1 /usr/fs-home/scripts/purge_Log.script
0
 
ozoCommented:
#oops, I thought you said 6pm
0
 
slokAuthor Commented:
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
 
davidmwilliamsCommented:
 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.