Posts:
25
From:
Registered:
10/17/09
|
|
|
|
how to create a timer for a command
Posted:
Nov 4, 2009 11:51 AM
To: OpenSolaris » help
|
|
ok i found how to shutdown the network with ifconfig ( card) down and to use it again i use ifconfig ( card) up, is there a form to make an script like a timer so it passes some time and it use the first command ifconfig down and after 1 hour it uses ifconfig up?
|
|
|
Posts:
98
From:
US
Registered:
3/6/06
|
|
|
|
Re: [osol-help] how to create a timer for a command
Posted:
Nov 4, 2009 12:00 PM
in response to: evelin
|
|
Use crontab. See the man page. -- Alan
evelin wrote: > ok i found how to shutdown the network with ifconfig ( card) down and to use it again i use ifconfig ( card) up, is there a form to make an script like a timer so it passes some time and it use the first command ifconfig down and after 1 hour it uses ifconfig up? > _______________________________________________ opensolaris-help mailing list opensolaris-help at opensolaris dot org
|
|
|
|
Posts:
25
From:
Registered:
10/17/09
|
|
|
|
Re: [osol-help] how to create a timer for a command
Posted:
Nov 4, 2009 8:08 PM
in response to: alanst
To: OpenSolaris » help
|
|
> Use crontab. See the man page. -- Alan > > evelin wrote: > > ok i found how to shutdown the network with > ifconfig ( card) down and to use it again i use > ifconfig ( card) up, is there a form to make an > script like a timer so it passes some time and it use > the first command ifconfig down and after 1 hour it > uses ifconfig up? > > > _______________________________________________ > opensolaris-help mailing list > opensolaris-help at opensolaris dot org
hello, i dont really know how to make an scriot i looked contrac but i dont get it, can u please explain it a little bit more easy with yust the things i want, please
|
|
|
|
Stewart Walters
stw@bgc.com.au
|
|
|
|
Re: [osol-help] how to create a timer for a command
Posted:
Nov 4, 2009 9:00 PM
in response to: evelin
|
|
evelin wrote: >> Use crontab. See the man page. -- Alan >> >> evelin wrote: >> >>> ok i found how to shutdown the network with >>> >> ifconfig ( card) down and to use it again i use >> ifconfig ( card) up, is there a form to make an >> script like a timer so it passes some time and it use >> the first command ifconfig down and after 1 hour it >> uses ifconfig up? >> >>> >>> >> _______________________________________________ >> opensolaris-help mailing list >> opensolaris-help at opensolaris dot org >> > > hello, i dont really know how to make an scriot i looked contrac but i dont get it, can u please explain it a little bit more easy with yust the things i want, please > Not contrac - crontab.
cron is one of the oldest of Unix utilities, found on all modern variants today. It's a scheduler. It schedules things.
cron reads a crontab - a dedicated file defining what should be run, when to run it, how often it should be re run after that etc.
If you don't have script writing skills, you can have crontab schedule the ifconfig (card) up/down commands directly.
Running a "crontab -l" will list the current user's crontab.
The simplest way for me to explain changing a crontab is - log on as the account who's crontab you wish to modify (i.e. the account who has the access to run the commands you want) and run "crontab -e". This will launch the default text editor and allow you to start modifying that account's crontab file.
The crontab file has a specific format, which is documented at http://en.wikipedia.org/wiki/Cron#Operators. If you've never used cron before, I'd recommend reading that whole page.
If that doesn't get you out of trouble here are some examples:
To run a 'ifconfig (card) down' at 3pm and a 'ifconfig (card) up' at 5pm, add the following two line's to root's crontab:
0 15 * * * ifconfig (card) down 0 17 * * * ifconfig (card) up
Of course, replace (card) with the name of the NIC you actually want to take down/up.
If you only want to perform those commands on card called e1000g0, and only on weekdays (Monday to Friday), then add these to root's crontab:
0 15 1-5 * * ifconfig e1000g0 down 0 17 1-5 * * ifconfig e1000g0 up
Running "man cron" and "man crontab" will give you further information as well.
Regards,
Stewart _______________________________________________ opensolaris-help mailing list opensolaris-help at opensolaris dot org
|
|
|
|
Posts:
25
From:
Registered:
10/17/09
|
|
|
|
Re: [osol-help] how to create a timer for a command
Posted:
Nov 5, 2009 8:27 AM
in response to: Stewart Walters
To: OpenSolaris » help
|
|
ok this is what i did but still not working
export EDITOR=/usr/bin/gedit
contrab -e yeso (yeso is my user) inside of gedit :
21 8 * * * gedit (gedit for beeing an example to see it if works)
but it doesn work, m i missing something
|
|
|
|
Posts:
98
From:
US
Registered:
3/6/06
|
|
|
|
Re: [osol-help] how to create a timer for a command
Posted:
Nov 5, 2009 9:13 AM
in response to: evelin
|
|
evelin wrote: > ok this is what i did but still not working > > export EDITOR=/usr/bin/gedit > > contrab -e yeso > (yeso is my user) > inside of gedit : > > 21 8 * * * gedit > (gedit for beeing an example to see it if works) > > but it doesn work, m i missing something >
gedit is not a good command to test, because it would try to start an editor when it is not connected to a terminal. Try this:
0 * * * * date >> /tmp/dateoutput
Then check the file /tmp/dateoutput every hour. You should see an entry added every hour as it runs the command.
-- Alan
_______________________________________________ opensolaris-help mailing list opensolaris-help at opensolaris dot org
|
|
|
|
|