Randomly create time in UNIX


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Randomly create time in UNIX
# 1  
Old 01-30-2015
Randomly create time in UNIX

Hey,

How can i create randomly create time N times.

Suppose i want to create data for a particualr date 5 times...

Code:
Mon Jan 19 11:42:50
Mon Jan 19 19:16:40
Mon Jan 19 12:12:33
Mon Jan 19 14:26:27
Mon Jan 19 12:29:53
Mon Jan 19 13:30:31

I want the script to create N times randome time i want to create for the same.
I will give the input N for the same.


Thanks,

Last edited by jim mcnamara; 01-30-2015 at 03:07 PM..
# 2  
Old 01-30-2015
A starting point?

Code:
$ for i in 1 2 3 4 5; do printf "%02d:%02d:%02d\n" $((RANDOM%24)) $((RANDOM%60)) $((RANDOM%60)); done
16:23:11
02:15:15
23:07:02
00:02:20
20:15:06

But what did you try?
This User Gave Thanks to Scott For This Post:
# 3  
Old 01-31-2015
Very nice solution Scott!
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Programming

Arduino UNIX Time - Syncing Computer UNIX Time to Arduino Time with Python

Just finished a quick Python script to send the current unix time over to the Arduino from macOS, so in the absence of GPS or some other way to get the unix timestamp (epoch time) to the Arduino, I can get my macOS and Arduino UNO synced to within a second. Normally, when the Arduino starts... (9 Replies)
Discussion started by: Neo
9 Replies

2. Shell Programming and Scripting

How to select lines randomly without replacement in UNIX?

Dear Folks I have one column of 15000 lines and want to select randomly 5000 of them in five different times without replacement. I am aware that command 'shuf' and 'sort -R' could select randomly those lines but I am not sure how could I avoid the replacement of selection line. Does anyone have... (10 Replies)
Discussion started by: sajmar
10 Replies

3. Shell Programming and Scripting

Convert UTC time into current UNIX sever time zone

Hi guys thanks for the help for my previous posts.Now i have a requirement that i download a XMl file which has UTC time stamp.I need to convert UTC time into Unix server timezone. For ex if the time zone of unix server is CDT then i need to convert into CDT.whatever may be the system time... (5 Replies)
Discussion started by: mohanalakshmi
5 Replies

4. Shell Programming and Scripting

Adding time to date time in UNIX shell scipting

I needed some help in adding a duration (in seconds) to a start time (in hhmmss format) and a start date (in mmddyy format) in order to get an end date and end time. The concept of a leap year is also to be considered while incrementing the day. The code/ function that I have formed so far is as... (3 Replies)
Discussion started by: codehelp04
3 Replies

5. UNIX for Dummies Questions & Answers

Converting string date time to unix time in AWK

I'd like to convert a date string in the form of sun aug 19 09:03:10 EDT 2012, to unixtime timestamp using awk. I tried This is how each line of the file looks like, different date and time in this format Sun Aug 19 08:33:45 EDT 2012, user1(108.6.217.236) all: test on the 17th ... (2 Replies)
Discussion started by: bkkid
2 Replies

6. Shell Programming and Scripting

How to get time duration between two human readable time stamp in Unix?

Here is two time I have: Jul 12 16:02:01 Jul 13 01:02:01 and how can I do a simple match to get difference between two time which is 09:00:00 Thanks in advance. (3 Replies)
Discussion started by: ford99
3 Replies

7. UNIX for Dummies Questions & Answers

create time sequence in bash

hi all, hope someone can assist in this. I'm trying to make a sequence of time in bash so that the output prints the following; 1950-01-01 1950-02-01 1950-03-01 ... 1999-11-01 1999-12-01 In R, i can issue the following command; t1 <- ISOdate(1950,1,1,0,0,0) t2 <-... (0 Replies)
Discussion started by: Muhammad Rahiz
0 Replies

8. UNIX for Advanced & Expert Users

How To Provide Time Sync Using Nts-150 Time Server On Unix Network?

can anybody tel lme,how to instal NTS -150 on a unix network,it needs some patch to fetch time frm serve,,?? (2 Replies)
Discussion started by: pesty
2 Replies

9. UNIX for Dummies Questions & Answers

time stamp of file create

Hi, Sounds a simple request but I also need (would like) to gather the seconds too. I'm not even sure if this is held. I would think it is, somewhere??!!?! I belive that stat would/could work but I don't do C (we'll not yet). Is there any comamnd line util I can use? SunOS. Cheers... (7 Replies)
Discussion started by: nhatch
7 Replies
Login or Register to Ask a Question