[olug] Anybody know anything about cron?

Jay Swackhamer Jay at RebootTheUser.com
Wed Dec 29 13:21:43 UTC 2004


the output of the ps command is sent to awk to parse the fields with a
default field separator of space, so $2 would be the pid of the xmms
process

i.e.
#ps -ef | grep xmms
jswackh  15807 24505  4 07:18 pts/6    00:00:00 xmms
           ^
           |


> Good call on that.  I get everything on here except this line:  kill
> `ps -ef | grep ${PROC} | awk ' { print $2 } '`.  Explain that to me.
>
> I get that it's calling kill, the param will be the PID from `ps -ef |
> grep ${PROC} but what does awk '{print $2 }' do and where is it getting
> the second variable from ($2) when there is only one param (xmms) being
> passed in the original call?
>
>
> On Dec 28, 2004, at 11:02 PM, Jay Swackhamer wrote:
>
>> In your script you would need to set all variables needed to run what
>> you
>> want.....think of running without any environment set
>> i.e.
>>
>> 0 5 * * * /home/whoever/bin/alarm
>> ###############################################################
>> #!/bin/sh
>> export TERM=xterm
>> export DISPLAY=:0.0
>>
>> cd /opt/music/big__rich/horse_of_a_different_color/
>> /usr/bin/xmms save_a_horse_ride_a_cowboy.mp3
>> ###################################################################
>>
>> Then you could setup a cron entry to find/kill after whenever
>>
>> 2 5 * * * /usr/local/bin/killprocs xmms
>> ##################################################################
>> #!/bin/bash
>>
>> PROC=$1
>>
>> kill `ps -ef | grep ${PROC} | awk ' { print $2 } '`
>> ##################################################################
>>
>>> I'm trying to set up cron to be an alarm on my box and to start
>>> playing
>>> a song or playlist using xmms. Nothing seems to work. I am on Mandrake
>>> 10.1 and all security is set to standard. After much trial and error
>>> and
>>> using this forum I got it to work by setting a script called 'alarm'
>>> with the following syntax:
>>>
>>> #!/bin/sh
>>> export TERM=xterm
>>> mpg123 "<song_title>"
>>>
>>> and my crontab looks like:
>>>
>>> * * * * * <home>/alarm
>>>
>>> First of all, yes the script is executable and the <home> and
>>> <song_title> are the actual directory and song title.
>>>
>>> That worked fine but it will load mpg123 in xterm and I can't see it
>>> so
>>> I have to manually search out the PID using 'ps aux | grep mpg' and
>>> kill
>>> it manually.
>>>
>>> I know I've done this on previous versions of Mandrake where my
>>> crontab
>>> was a very simple line such as: * * * * * /usr/bin/xmms "<song_title>"
>>>
>>> Anyone know any ways of making cron start an X app?
>>>
>>> By the way, as a test, I ran a cron job to do: * * * * * /usr/bin/xmms
>>> and redirected the output to a log file and got the following message:
>>> "** CRITICAL **: Unable to open display".
>>>
>>> So, I thought to add localhost to the xhosts access control using
>>> "xhost
>>> + localhost". It was successfully added but still nothing.
>>>
>>> I've tried using "at" also and it won't work and I've tried creating
>>> cron jobs through webmin and when you click on the link there is
>>> nothing
>>> there, the page doesn't even move.
>>>
>>> Any suggestions?
>>> _______________________________________________
>>> OLUG mailing list
>>> OLUG at olug.org
>>> http://lists.olug.org/mailman/listinfo/olug
>>>
>>
>>
>> --
>> Jay Swackhamer
>> Reboot The User
>> 15791 West Dodge Road
>> Suite 135
>> Omaha, NE 68118
>> (402) 933-6449
>> (402) 933-6456 Fax
>> http://www.RebootTheUser.com
>> _______________________________________________
>> OLUG mailing list
>> OLUG at olug.org
>> http://lists.olug.org/mailman/listinfo/olug
>>
>
>


-- 
Jay Swackhamer
Reboot The User
15791 West Dodge Road
Suite 135
Omaha, NE 68118
(402) 933-6449
(402) 933-6456 Fax
http://www.RebootTheUser.com



More information about the OLUG mailing list