LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   how to write a script (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-write-a-script-849749/)

Abdalla 12-12-2010 08:17 AM

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.

mesiol 12-12-2010 08:56 AM

Hi,

best you read Bash Beginners Guide.

colucix 12-12-2010 09:07 AM

Quote:

Originally Posted by Abdalla (Post 4188699)
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.

fernfrancis 12-12-2010 11:42 PM

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

catkin 12-13-2010 12:37 AM

You might want the -new-window option documented at https://developer.mozilla.org/en/Command_Line_Options

TB0ne 12-13-2010 07:30 AM

Quote:

Originally Posted by fernfrancis (Post 4189375)
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.

MTK358 12-13-2010 12:50 PM

Or you can use the "--display :0" option for Firefox when launching from cron.

devnull10 12-13-2010 01:11 PM

Do you want it to happen just once or every monday?

Abdalla 12-30-2010 12:09 PM

Thanks Guys for the replies.
I was somewhere away.
Regarding the last question by devnull10 every monday if possible.


All times are GMT -5. The time now is 09:43 AM.