Solved

Cron jobs and scripts

Posted on 1998-11-22
5
213 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 84

Expert Comment

by:ozo
Comment Utility
0 18 * * 1 /usr/fs-home/scripts/purge_Log.script
0
 
LVL 84

Expert Comment

by:ozo
Comment Utility
#oops, I thought you said 6pm
0
 
LVL 4

Accepted Solution

by:
davidmwilliams earned 50 total points
Comment Utility
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
Comment Utility
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
Comment Utility
 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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.:

728 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now