Unable to set just year with Linux date command [closed] - linux

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
For some reason I fail to update year only using date command
date
Tue Mar 4 20:15:42 IST 2014
date '+%Y' -s '2013'
date
Tue Mar 4 20:13:01 IST 2014
I tried it on both RedHat and Ubuntu...
NTP is not running...

Apparently to change the date you have to use the complete setting syntax.
date --set="YYYYmmdd HH:MM"
Here is a way to achieve your demand :
date --set="$(date +'2013%m%d %H:%M')"
This way you maintain month, day, hour and minute and change year.

Related

Linux date timezone [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 4 years ago.
Improve this question
I have a question about timezone and the output of the linux date command. Is it standard or daylight? date +%Z returns EDT.
Is there a way to change the timezone returned by date +%Z from EDT to EST?
The timezone information is stored in the $TZ environment variable.
TZ=EST date +%Z
But why? If you need the string EST in the output, just echo EST :-)

Command last in Linux [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 5 years ago.
Improve this question
When the last command lists the entries, what is the default format at the duration?For example: if I have an entry with a duration such as (03:43) does that mean that the user was logged on for 3 hours and 43 minutes?
And if there's an entry with a duration such as (3+02:56) does that mean that the user was logged on for 3 days 2 hours and 56 minutes?
Yeah, for every OS I've used, duration: (days+hours:minutes)
Check out this answer

How to run cron job on 29th of every month? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
Is it possible to write a single cron expression which runs on the 29th day of every month OR the last day if the month has only 28 days (e.g. February)?
Single cron syntax is not possible. You can do last day of the month
0 0 12 L 1/1 ? *.
It will trigger last day of every month.
0 0 12 29 1/1 ? *.
If you trigger like this you will miss non leap year February.

CRON to Run on Weekdays [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
I have a cronjob set to run as
3 6 10 * 1-6 wget'http://...'
How will this execute ? I intend to run it at 6:03 AM on the 10th Of Every Month expect on Sundays.
I am confused as it ran on Saturday, even when the date was not 10th.
Please advise if there is an error with my command or could it be something else ?
The way you have this setup, your command will execute EITHER when the day of the week is 1-6 OR when the day of month is 10.

How can I get the current date and time in the terminal and set a custom command in the terminal for it? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
I have to check the time in a Linux terminal.
What is the command for getting date and time in a Linux terminal?
Is there a way in which we can set a custom function?
The command is date
To customise the output there are a myriad of options available, see date --help for a list.
For example, date '+%A %W %Y %X' gives Tuesday 34 2013 08:04:22 which is the name of the day of the week, the week number, the year and the time.
You can use date to get time and date of a day:
[pengyu#GLaDOS ~]$date
Tue Aug 27 15:01:27 CST 2013
Also hwclock would do:
[pengyu#GLaDOS ~]$hwclock
Tue 27 Aug 2013 03:01:29 PM CST -0.516080 seconds
For customized output, you can either redirect the output of date to something like awk, or write your own program to do that.
Remember to put your own executable scripts/binary into your PATH (e.g. /usr/bin) to make it invokable anywhere.

Resources