Solved

Cron jobs and scripts

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
linux  centos   virtualization network quetion 6 81
Skill Development 15 177
Problem logging tar errors 11 58
remove one line from a file in solaris 8 29
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
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.:
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

809 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