草庐IT

date_format

全部标签

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 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

linux - 在 bash 中使用'rm'- 到 'delete by date' 有什么简单的方法吗?

我今天注意到(在愉快地使用bash进行了大约8年的黑客攻击之后),没有简单的方法可以使用“rm”来“按日期删除”。因此,解决方案是围绕诸如rm、ls、find、awk和sed等命令的组合来传输内容。例如,我想删除工作目录中自2009年以来的所有文件,典型的方法是什么?我想到了以下内容,它非常丑陋,只有在“rm”设置为跳过目录时才应该运行(否则您将删除父目录):ls-la|awk'{if(substr($6,0,5)==2009)print$8}'|xargsrm最优雅和最离谱的过度设计解决方案的分数。 最佳答案 我会结合find和r

ubuntu : vmlinuz or crash file not a supported file format 上的崩溃转储

我正在尝试使用crash实用程序分析我的ubuntu机器上的故障转储,如下所示$sudocrash/boot/System.map-3.2.0-23-generic-pae/boot/vmlinuz-3.2.0-23-generic-pae_usr_sbin_ietd.0.crash但它返回错误为crash:/boot/vmlinuz-3.2.0-23-generic-pae:notasupportedfileformat根据崩溃实用程序语法,我已正确提供参数crashcoredump我在这里做错了什么?更新:启动目录中的vmlinuz文件似乎是bzimage压缩的$filevmlin

java - 无效文件(坏魔数(Magic Number)): Exec format error

当我尝试设置类路径时出现以下错误。我正在使用CentyOS。我正在尝试在命令提示符下编译一个java文件,因为我正在设置类路径。在Intellij中执行相同的java程序时,它运行良好。从命令提示符执行相同的操作时,它显示缺少jar的错误,因此我将类路径添加到出现错误的库中。[root@aadmin]#exportCLASSPATH=/home/admin/TagAPI/lib/org.json-20120521.jar;/home/admin/TagAPI/lib/testng-6.8.21.jarinvalidfile(badmagicnumber):Execformaterror

linux - 使用 linux 命令 "date"添加一些特定时间

在linux中,date可以帮助我打印当前时间。如果要打印当前时间+1小时,我应该给什么选项? 最佳答案 在Linux上只需使用-d(或--date)对日期进行一些数学计算:date-d'+1hour''+%F%T'#^^^^^^^^^^^^例如:$date'+%F%T'2013-04-2210:57:24$date-d'+1hour''+%F%T'2013-04-2211:57:24#^Mac操作系统警告,以上仅适用于Linux,不适用于MacOS。在MacOS上,等效的命令是date-v+1H

linux - git:gitk 有 "Sort by date"的命令行选项吗?

我正在尝试为gitk找到一个命令行选项,它与“查看/编辑View...”窗口中的“严格按日期排序”具有相同的效果。与GUI中可用的选项相比,mangitk显示的选项数量非常有限。 最佳答案 mangitk至少提到它确实采用了与gitrev-list相同的选项,包括--date-orderThisoptionissimilarto--topo-orderinthesensethatnoparentcomesbeforeallofitschildren,butotherwisethingsarestillorderedinthecomm

linux - insmod错误: inserting './hello.ko' : -1 Invalid module format"

我刚刚制作了我的第一个驱动模块,继LDD3之后的helloworld模块。然而不幸的是遇到了这个错误:insmod:errorinserting'./hello.ko':-1Invalidmoduleformat.我在Ubuntu11.04和我的环境中执行此操作:$uname-r2.6.38-8-generic我得到这样的内核源代码:sudoapt-cachesearchlinux-sourcelinux-source-LinuxkernelsourcewithUbuntupatcheslinux-source-2.6.38-Linuxkernelsourceforversion2.6

c - fprintf,错误 : format not a string literal and no format arguments [-Werror=format-security

当我尝试在Ubuntu上编译fprintf(stderr,Usage)时,我遇到了这个错误:error:formatnotastringliteralandnoformatarguments[-Werror=format-security但是当我在其他linux发行版(RedHat、Fedora、SUSE)上编译时编译成功。有人有想法吗? 最佳答案 你应该使用fputs(Usage,stderr);如果您不进行格式化,则无需使用fprintf。如果要使用fprintf,请使用fprintf(stderr,"%s",Usage);de

php - number_format() 导致错误 "A non well formed numeric value encountered"

我正在使用number_format将float舍入为仅2位小数。问题是我的一些输入没有超过2个小数位开头。所以代码:number_format($value,2)如果它没有足够的十进制数字,它不会和平地添加0,而是在Apache日志中引发错误,这是不可取的。因此number_format(2.1,2)或number_format(0,2)将在Apache日志中引发错误。[ThuJun3017:18:042011][error][client127.0.0.1]PHPNotice:Anonwellformednumericvalueencounteredin/home/tahoang/