草庐IT

date_end

全部标签

linux - 使用/bin/date 更改系统时间

我正在尝试通过脚本更改系统时间。基本上是命令date-s""不起作用,因为我以用户www-data身份运行命令。虽然我编辑了/etc/sudoers文件将root权限授予用户www-data,我仍然无法更改或设置时间。可能是什么原因? 最佳答案 编辑/etc/sudoers后,做一个sudodate-s命令。这将从“根”用户执行实际的日期命令。仅仅编辑/etc/sudoers是不够的,因为它不会给用户一个root,但它会提供一个使用sudo实用程序从用户变成root的能力。 关于linu

linux - 为什么 php 'date' 函数返回错误的时间(大约 24 秒)?

我在gentooLinux(php版本5.2.10-pl0-gentoo)上运行了以下小的php片段:#!/usr/bin/php5产生的输出如下:date("d.m.yH:i:s")yields:27.03.1407:05:27while'date'yieldsThuMar2707:05:03UTC2014.date("d.m.yH:i:s")yields:27.03.1407:05:28while'date'yieldsThuMar2707:05:04UTC2014.date("d.m.yH:i:s")yields:27.03.1407:05:29while'date'yields

linux - 获取下周星期二和星期三,使用 Linux date 命令

在Linuxshell中,您可以执行以下操作:date-d"nextTuesday"下个星期二。我的问题是:我想得到下周的星期二。因此,如果我目前在星期一,我希望它提前7天到下周,然后评估“下星期二”。有没有办法以某种方式链接日期评估?进一步详细说明,如果我在星期三,那么下周的星期二还有6天 最佳答案 date比你想象的要聪明~:date-d"nexttuesday"TueFeb200:00:00GMT2016~:date-d"1weeknexttuesday"TueFeb900:00:00GMT2016~:如果你想得到下周的星期二

linux - Perl one-liner 是否可以为给定的每个文件 arg 执行 END block

对于Perl单行代码,当使用-p或-n标志时是否可以使END{}block执行每个文件一次,而不是整个程序一次?换句话说,当我写:perl-ne'$count++if/.../;END{print"$ARGV:$count"if$count>0}'mysourcedir/*.html我想为每个文件执行一次ENDblock,而不是在程序执行结束时全局执行一次。目前我只是为此使用xargs,但想知道Perl是否可能有一些替代标志用于该行为。echomysourcedir/*.html|xargs-n1perl-ne'$count++if/.../;END{print"$ARGV:$coun

c - 如何在 char 数组中获取 `date` 命令的输出?

我想把GNU/Linuxdate命令的输出放在一个字符数组中。例子:chararray[25];$dateThuJul1909:21:31IST2012printf("%s",array);/*Shoulddisplay"ThuJul1909:21:31IST2012"*/我试过这个:#include#include#defineSIZE50intmain(){chararray[SIZE];sprintf(array,"%s",system("date"));printf("\nGotthis:%s\n",array);return0;}但输出显示数组中的NULL。

linux - 用户目录 "End of script output before headers"中的 Apache CGI

我知道有一些关于这个主题的问题,但似乎没有一个能解决我的问题。参见this或this或this.我在Linux、Fedora21上,我正在尝试为每个用户目录启用CGI脚本。我关注了these说明,但没有成功。我得到错误:[cgi:error]Endofscriptoutputbeforeheaders:test.cgitest.cgi是一个可执行的sh文件,包含一个非常简单的脚本:#!/usr/bin/shecho"Content-type:text/plain"echo""echo"Hello"它有可执行标志并且从shell运行没有问题。我也尝试过使用Python:同样的结果。我还禁

linux - .bashrc 语法错误 : unexpected end of file

我遇到了意外的文件结束错误。我不太确定如何修复它。#Sourceglobaldefinitionsif[-f/etc/bashrc];then./etc/bashrcfi#UserspecificaliasesandfunctionsexportPS1='\[\e[0;32m\]\u\[\e[m\]\[\e[1;34m\]\w\[\e[m\]\[\e[1;32m\]\$\[\e[m\]\[\e[1;37m\]'exportLS_COLORS='di=35;1'aliasla='ls-lah'aliascdu='cd/home/hzhang/primary'#moduleloadgnu-

linux - 从 systemd bash 内联脚本创建 filename_$(date %Y-%m-%d)

我正在尝试执行一个systemd计时器,并希望将执行脚本的输出按日期保存在一个文件中。这是我在.service文件中的ExecStart脚本:ExecStart=/bin/bash-c'echo$(date+%Y-%m-%d)>>/home/username/test_output_$(date+%Y-%m-%d).log'这会创建文件,但会添加一个“哈希”而不是月份名称:~/test_output_2017-ea3c0c2dd56c499a93412641e41008db-01.log内容相同:2017-ea3c0c2dd56c499a93412641e41008db-01如果我在s

linux - 在 bash 脚本中,if 语句出现意外的 "syntax error: unexpected end of file"

这个问题在这里已经有了答案:Bashsyntaxerror:unexpectedendoffile(21个回答)关闭6年前。当我运行以下代码片段时#!/bin/bashif["foo"="foo"];thenecho"true"elseecho"false"fiecho"end"我明白了sfm_write_buffer_test.sh:line9:syntaxerror:unexpectedendoffile这没有任何意义。echo语句工作正常,但是当遇到if语句时,它会给出上述错误。

Linux shell 脚本 : make a folder with the current date name

我正在尝试制作一个简单的备份脚本,但在创建名称为当前日期的文件夹时遇到问题我的脚本就是这样,基本上问题在最后一行drivers=$(ls/media/)declare-ic=0forwordin$driversdoecho"($c)$word"c=c+1doneread-n1driveechoc=0forwordin$driversdoif[$c-eq$drive]thenbackuppath="/media/$word/backup"fic=c+1doneecho"doingbackupto$backuppath"cp-r/home/stefanos/Programming$back