Solved

Cron jobs and scripts

Posted on 1998-11-22
5
219 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 84

Expert Comment

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

Expert Comment

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

Accepted Solution

by:
davidmwilliams earned 50 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

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

Question has a verified solution.

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

A metadevice consists of one or more devices (slices). It can be expanded by adding slices. Then, it can be grown to fill a larger space while the file system is in use. However, not all UNIX file systems (UFS) can be expanded this way. The conca…
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 get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…

691 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