LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > Solaris / OpenSolaris
User Name
Password
Solaris / OpenSolaris This forum is for the discussion of Solaris, OpenSolaris, OpenIndiana, and illumos.
General Sun, SunOS and Sparc related questions also go here. Any Solaris fork or distribution is welcome.

Notices


Reply
  Search this Thread
Old 09-22-2006, 07:10 AM   #1
ignignokt
LQ Newbie
 
Registered: Sep 2006
Posts: 19

Rep: Reputation: 0
Auto Run Scripts


I have a script (SH) that needs to run automatically every couple hours on a Solaris 9 box. Is this possible to achieve? If not, what are some alternatives to do this? Thanks for any help!
 
Old 09-22-2006, 07:17 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
you need to look into cron, that'll sort you out no problems.
 
Old 09-22-2006, 09:15 AM   #3
ignignokt
LQ Newbie
 
Registered: Sep 2006
Posts: 19

Original Poster
Rep: Reputation: 0
thanks for the help. will research it
 
Old 09-22-2006, 09:27 AM   #4
ignignokt
LQ Newbie
 
Registered: Sep 2006
Posts: 19

Original Poster
Rep: Reputation: 0
question

i tried to run "crontab -e" to edit the crontab file and im getting the following:

sh: emacs: not found
crontab: temporary file empty

It will run on a Solaris 8 install correct??
 
Old 09-22-2006, 09:56 AM   #5
mdhmi
Member
 
Registered: Dec 2005
Location: Detroit, Michigan
Distribution: Ubuntu
Posts: 86

Rep: Reputation: 15
Verify whichever user id you are using has access to cron. Your id needs to either be in /etc/cron.d/cron.allow or not in /etc/cron.d/cron.deny.

Type:

EDITOR=vi ; export EDITOR
crontab -e

Insert a line something like:

0 0, 2, 4, 8, 10, 12, 14, 16, 18, 20, 22 * * * /usr/bin/myscript
 
Old 09-22-2006, 10:15 AM   #6
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
that's a very odd way to define a run every two hours... what's wrong with a nice simple "0 */2 * * *" ?
 
Old 09-22-2006, 10:42 AM   #7
ignignokt
LQ Newbie
 
Registered: Sep 2006
Posts: 19

Original Poster
Rep: Reputation: 0
I checked the editor and it was vi already, but giving me the same error. Can I just create a crontab file and put it in a directory to achieve this?
 
Old 09-22-2006, 11:07 AM   #8
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
Quote:
Originally Posted by acid_kewpie
what's wrong with a nice simple "0 */2 * * *" ?
Probably the fact this syntax is not recognized by Solaris crontab.c: http://cvs.opensolaris.org/source/xr...cron/crontab.c

Code:
crontab: error on previous line; unexpected character found in line.
crontab: errors detected in input, no crontab file generated.
 
Old 09-22-2006, 11:09 AM   #9
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
Quote:
Originally Posted by ignignokt
I checked the editor and it was vi already, but giving me the same error.
Try:
Code:
env EDITOR=vi crontab -e
Quote:
Can I just create a crontab file and put it in a directory to achieve this?
Yes, but it is unsafe, and you'll have to restart cron manually.
 
Old 09-22-2006, 11:15 AM   #10
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
Quote:
Originally Posted by jlliagre
Probably the fact this syntax is not recognized by Solaris crontab.c: http://cvs.opensolaris.org/source/xr...cron/crontab.c

Code:
crontab: error on previous line; unexpected character found in line.
crontab: errors detected in input, no crontab file generated.
how about neither of us ever mention this again?
 
Old 09-22-2006, 11:21 AM   #11
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
You have my word !
 
Old 09-22-2006, 11:42 AM   #12
ignignokt
LQ Newbie
 
Registered: Sep 2006
Posts: 19

Original Poster
Rep: Reputation: 0
jlliagre..i tried the line you gave me and still the same error. I tried it on my Solaris 10 box and it works fine..but our production box has solaris 8.
 
Old 09-22-2006, 12:12 PM   #13
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
Hmm, how can setting the editor to vi give you an emacs error message ?

What says this command:
Code:
type vi
?
 
Old 09-22-2006, 12:16 PM   #14
ignignokt
LQ Newbie
 
Registered: Sep 2006
Posts: 19

Original Poster
Rep: Reputation: 0
the output is:

vi is hashed (/usr/bin/vi)
 
Old 09-22-2006, 01:34 PM   #15
mdhmi
Member
 
Registered: Dec 2005
Location: Detroit, Michigan
Distribution: Ubuntu
Posts: 86

Rep: Reputation: 15
ignignokt - refresh my memory - what is the exact message you get when you run "crontab -e" ?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Digital Picture Frame Startup Scripts - Auto Login gtwilliams Linux - General 4 08-01-2006 04:43 PM
[c/c++] Run scripts aalex77 Programming 6 05-06-2006 02:55 PM
Auto Restart scripts for apps Ghent Linux - Software 3 06-20-2005 06:33 PM
as promised scripts for auto LFS NGraphiX Linux From Scratch 11 11-04-2002 05:49 AM
Auto Logon and Auto Run OKCHelpDesk Linux - General 0 05-03-2002 02:02 PM

LinuxQuestions.org > Forums > Other *NIX Forums > Solaris / OpenSolaris

All times are GMT -5. The time now is 01:02 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration