简体   繁体   English

通过crontab中的脚本打开JPG文件

[英]Opening a JPG file by a script in crontab

I'm trying to make a pomodoro script, just for fun haha. 我正在尝试制作番茄剧本,只是为了好玩哈哈。 The ideia is that every 30 minutes, a pic pop up on the screen... so its coffee time! 意思是每30分钟,屏幕上会弹出一张图片......所以它的咖啡时间! ;) I planned something simple, like a scrip that opens a pic, run by the crontab. ;)我计划了一些简单的东西,比如打开pic的脚本,由crontab运行。 I got a script that opens a jpg image using EOG. 我有一个脚本,使用EOG打开jpg图像。 Something like that: 像这样的东西:

#!/bin/bash
eog -n /home/lscardeal/Pictures/pic.jpg

It works when i run it myself, but it doesn't open the file when its run by the crontab. 当我自己运行它时它可以工作,但是当它由crontab运行时它不会打开文件。 My crontab runs the script, but the pic doesn't open. 我的crontab运行脚本,但pic没有打开。 How can i make it work? 我怎样才能使它工作?

thx 谢谢

Check if this script works: 检查此脚本是否有效:

#!/bin/bash

#Export DISPLAY
export DISPLAY=:0.0

#Call Gnome EOG
/usr/bin/eog -f /home/user/image.png &

#Time to display
sleep 100

killall eog

Tks TKS

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM