在 CentOS 系统中,你可以使用多种方法来获取当前的时间戳。以下是几种常用的方法:
使用 date
命令:
date +%s
date +%s%3N
或者date +%s | xargs -I {} echo "{}$(printf '%03d' $(date +%N | cut -b1-3))"
使用 python
脚本:
如果你已经安装了 Python,可以使用以下命令获取时间戳:
python -c 'import time; print(int(time.time()))'
python -c 'import time; print(int(time.time() * 1000))'
使用 perl
脚本:
如果系统中有 Perl,也可以用来获取时间戳:
perl -MTime::HiRes -e 'printf("%d\n", Time::HiRes::time())'
perl -MTime::HiRes -e 'printf("%d\n", Time::HiRes::time() * 1000)'
这些方法应该可以帮助你在 CentOS 系统中获取当前的时间戳。