LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-12-2010, 08:17 AM   #1
Abdalla
LQ Newbie
 
Registered: Oct 2010
Posts: 7

Rep: Reputation: 0
how to write a script


Hi Guys
Can anyone tell me how to write a command that open2 mozila firefoc at 3 p.m. on monday using CentOs 5.
 
Old 12-12-2010, 08:56 AM   #2
mesiol
Member
 
Registered: Nov 2008
Location: Lower Saxony, Germany
Distribution: CentOS, RHEL, Solaris 10, AIX, HP-UX
Posts: 731

Rep: Reputation: 137Reputation: 137
Hi,

best you read Bash Beginners Guide.
 
1 members found this post helpful.
Old 12-12-2010, 09:07 AM   #3
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
Quote:
Originally Posted by Abdalla View Post
Hi Guys
Can anyone tell me how to write a command that open2 mozila firefoc at 3 p.m. on monday using CentOs 5.
Scheduling commands is usually performed by means of crontabs (see man crontab for details) but they are intended for applications that don't require an active display to be executed. In your case better to use the at command to schedule the job, since it retains your current environment and is aware of the currently active display. This assumes that a X session is active at the time of the execution and that the assigned DISPLAY value is the same as that one assigned at the job submission time. See the manual page for at to learn about its usage and feel free to ask if in doubt.

Here is an old but still valid article about job scheduling in Linux: http://www.linuxjournal.com/article/4087. Hope this helps.
 
1 members found this post helpful.
Old 12-12-2010, 11:42 PM   #4
fernfrancis
Member
 
Registered: Feb 2009
Location: Goa(India)-Sharjah(UAE)
Distribution: RHEL,centos,fedora,ubuntu
Posts: 229

Rep: Reputation: 18
i think this should help you

#!/bin/bash
#########################################
######### open first firefox ###########
#########################################

firefox &

#########################################
######### wait for 2sec #################
#########################################

sleep 2s

########################################
########## start second instance########

firefox &

exit(0)



schedule this as a cron job to whatever day and time you need
is this what you are looking for ?

hope this helps you

Last edited by fernfrancis; 12-12-2010 at 11:43 PM.
 
Old 12-13-2010, 12:37 AM   #5
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
You might want the -new-window option documented at https://developer.mozilla.org/en/Command_Line_Options
 
1 members found this post helpful.
Old 12-13-2010, 07:30 AM   #6
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 18,995

Rep: Reputation: 4327Reputation: 4327Reputation: 4327Reputation: 4327Reputation: 4327Reputation: 4327Reputation: 4327Reputation: 4327Reputation: 4327Reputation: 4327Reputation: 4327
Quote:
Originally Posted by fernfrancis View Post
i think this should help you
Code:
#!/bin/bash
#########  open first firefox ###########
firefox &

######### wait for 2sec #################
sleep 2s

########## start second instance########
firefox &
exit(0)
schedule this as a cron job to whatever day and time you need is this what you are looking for ?
This won't work. If you schedule it, it'll run as a separate user (probably root), and even IF you do schedule it as the 'real' user you want, unless you give it a display variable (to tell it which X display to put the windows ON), it won't do anything except fail.

This link: http://www.codecoffee.com/tipsforlinux/articles/23.html explains more.
 
Old 12-13-2010, 12:50 PM   #7
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721
Or you can use the "--display :0" option for Firefox when launching from cron.
 
Old 12-13-2010, 01:11 PM   #8
devnull10
Member
 
Registered: Jan 2010
Location: Lancashire
Distribution: Slackware Stable
Posts: 553

Rep: Reputation: 116Reputation: 116
Do you want it to happen just once or every monday?
 
Old 12-30-2010, 12:09 PM   #9
Abdalla
LQ Newbie
 
Registered: Oct 2010
Posts: 7

Original Poster
Rep: Reputation: 0
Thanks Guys for the replies.
I was somewhere away.
Regarding the last question by devnull10 every monday if possible.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
How to write a script blck_kenzo Linux - Newbie 2 05-25-2009 12:29 AM
Better way to write this script faizlo Programming 6 01-08-2009 02:25 AM
how to write this script? MeganageM Linux - Newbie 1 03-10-2004 05:01 PM
Help with a script I need to write... cmfarley19 Programming 9 12-06-2003 12:10 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02: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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration