相关疑难解决方法(0)

如何从终端找到我的用户 ID (UID)?

标题说明了一切。我需要从终端运行什么命令来查找我的用户 ID (UID)?

command-line user-management

253
推荐指数
5
解决办法
48万
查看次数

帮助使用 crontab 播放声音

我想使用 crontab 每小时和 15,30 和 45 分钟播放大本钟的录音。

到目前为止,我正在使用 mplayer2 和以下任务:

0 1,13 * * * mplayer -really-quiet ~/bin/bigben/Clock_Chime_01.ogg -volume 100 >/dev/null 2>&1 # JOB_ID_75
0 2,14 * * * mplayer -really-quiet ~/bin/bigben/Clock_Chime_02.ogg -volume 100 >/dev/null 2>&1 # JOB_ID_76
0 3,15 * * * mplayer -really-quiet  ~/bin/bigben/Clock_Chime_03.ogg -volume 100 >/dev/null 2>&1 # JOB_ID_77
0 4,16 * * * mplayer -really-quiet  ~/bin/bigben/Clock_Chime_04.ogg -volume 100 >/dev/null 2>&1 # JOB_ID_78
0 5,17 * * * mplayer -really-quiet  ~/bin/bigben/Clock_Chime_05.ogg -volume 100 >/dev/null 2>&1 # JOB_ID_79 …
Run Code Online (Sandbox Code Playgroud)

sound cron

9
推荐指数
2
解决办法
4426
查看次数

无法为我的 scrapy 程序创建 crontab 作业

我写了一个小的 Python 抓取工具(使用 Scrapy 框架)。刮板需要无头浏览...我正在使用 ChromeDriver。

当我在没有任何 GUI 的 Ubuntu 服务器上运行此代码时,我必须安装 Xvfb 才能在我的 Ubuntu 服务器上运行 ChromeDriver(我遵循了本指南

这是我的代码:

class MySpider(scrapy.Spider):
    name = 'my_spider'

    def __init__(self):
        # self.driver = webdriver.Chrome(ChromeDriverManager().install())
        chrome_options = Options()
        chrome_options.add_argument('--headless')
        chrome_options.add_argument('--no-sandbox')
        chrome_options.add_argument('--disable-dev-shm-usage')
        self.driver = webdriver.Chrome('/usr/bin/chromedriver', chrome_options=chrome_options)
Run Code Online (Sandbox Code Playgroud)

我可以从 Ubuntu shell 运行上面的代码并且它执行时没有任何错误:

ubuntu@ip-1-2-3-4:~/scrapers/my_scraper$ scrapy crawl my_spider
Run Code Online (Sandbox Code Playgroud)

现在我想设置一个 cron 作业来每天运行上述命令:

# m h  dom mon dow   command
PATH=/usr/local/bin:/home/ubuntu/.local/bin/
05 12 * * * cd /home/ubuntu/scrapers/my_scraper && scrapy crawl my_spider >> /tmp/scraper.log 2>&1
Run Code Online (Sandbox Code Playgroud)

但是 crontab 作业给了我以下错误:

Traceback (most recent call …
Run Code Online (Sandbox Code Playgroud)

python command-line cron google-chrome selenium

8
推荐指数
1
解决办法
936
查看次数