How to open xterm from script being runned by cron?

iBrazilian2

I've got cronjob running this script every 20 minutes but I cannot understand how to make xterm open with it..

#!/bin/bash

xterm -hold -e "echo Time to relax"
play -q /home/username/music/relax.mp3 trim 0 01:20
sleep 120
exit 0

and in crontab -e

*/20 * * * * /home/username/Desktop/alarm.sh

The script runs fine but I just can't get xterm to open, Am I doing anything wrong here? When I run the script via terminal, ex: sh /home/username/Desktop/alarm.sh the terminal opens just fine and the song plays as well..

hek2mgl

When the script is not started from within a X session, which is the case for a cron script, you need to pass the DISPLAY environment variable:

DISPLAY=:0 xterm -hold -e "echo Time to relax"

If you are running a standard desktop system :0 should work as the value, otherwise you need to pass the correct value for your system.

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

如何从cron运行的脚本中打开xterm?

来自分类Dev

can't import modules into a node script if it runs from cron

来自分类Dev

Preventing application from being closed when a file is open in Python

来自分类Dev

Open intent from URL using Java Script is not working on production - DeepLink

来自分类Dev

How to open the app from the background task in iOS?

来自分类Dev

How to prevent files from being checked out to the default changelist in perforce?

来自分类Dev

How to check what prevents an object from being eligble for garbage collection?

来自分类Dev

How can I prevent a window from being resized with tkinter?

来自分类Dev

How can one prevent a git branch from being merged into another?

来自分类Dev

How stop rpcbind from being started on Arch Linux?

来自分类Dev

Cron Job Killing and Restarting Python Script

来自分类Dev

How to remove script initialisation from javaScript file

来自分类Dev

How to open photo gallery by clicking a button from a camera overlay?

来自分类Dev

How to stop the normal force from being too small on a 2D rigidbody? (Java 2D)

来自分类Dev

How can I prevent a PDF file from being downloaded or printed with PHP or JavaScript?

来自分类Dev

在Windows的localhost上的PHP Script上运行Cron Job

来自分类Dev

Tell PHP to enable or use GD when running script via cron

来自分类Dev

通过cron运行perl-script kpcli失败

来自分类Dev

How to stop Powershell credential request from prompting in a long script?

来自分类Dev

How to remove junk characters from the file generated by script command in linux

来自分类Dev

Error in fsproj file prevents it from being opened

来自分类Dev

Preventing properties from being added to a JavaScript object

来自分类Dev

配置文件中的“ Xterm”或“ xterm”

来自分类Dev

在xterm内设置xterm的scaleHeight属性

来自分类Dev

How do I open an outlook .msg file from my harddrive that is NOT in outlook?

来自分类Dev

How to return value from child window to parent window using window.open in Javascript?

来自分类Dev

Ext4.2.1 How to open a new browser tab with widget inside from another browser tab

来自分类Dev

How do I open up a random url from a list of url's in a new time each time it is clicked?

来自分类Dev

如何执行Xterm

Related 相关文章

  1. 1

    如何从cron运行的脚本中打开xterm?

  2. 2

    can't import modules into a node script if it runs from cron

  3. 3

    Preventing application from being closed when a file is open in Python

  4. 4

    Open intent from URL using Java Script is not working on production - DeepLink

  5. 5

    How to open the app from the background task in iOS?

  6. 6

    How to prevent files from being checked out to the default changelist in perforce?

  7. 7

    How to check what prevents an object from being eligble for garbage collection?

  8. 8

    How can I prevent a window from being resized with tkinter?

  9. 9

    How can one prevent a git branch from being merged into another?

  10. 10

    How stop rpcbind from being started on Arch Linux?

  11. 11

    Cron Job Killing and Restarting Python Script

  12. 12

    How to remove script initialisation from javaScript file

  13. 13

    How to open photo gallery by clicking a button from a camera overlay?

  14. 14

    How to stop the normal force from being too small on a 2D rigidbody? (Java 2D)

  15. 15

    How can I prevent a PDF file from being downloaded or printed with PHP or JavaScript?

  16. 16

    在Windows的localhost上的PHP Script上运行Cron Job

  17. 17

    Tell PHP to enable or use GD when running script via cron

  18. 18

    通过cron运行perl-script kpcli失败

  19. 19

    How to stop Powershell credential request from prompting in a long script?

  20. 20

    How to remove junk characters from the file generated by script command in linux

  21. 21

    Error in fsproj file prevents it from being opened

  22. 22

    Preventing properties from being added to a JavaScript object

  23. 23

    配置文件中的“ Xterm”或“ xterm”

  24. 24

    在xterm内设置xterm的scaleHeight属性

  25. 25

    How do I open an outlook .msg file from my harddrive that is NOT in outlook?

  26. 26

    How to return value from child window to parent window using window.open in Javascript?

  27. 27

    Ext4.2.1 How to open a new browser tab with widget inside from another browser tab

  28. 28

    How do I open up a random url from a list of url's in a new time each time it is clicked?

  29. 29

    如何执行Xterm

热门标签

归档