I wanted to write a small script which displays a image or play a song at the particular time. What is the best way(which consumes less RAM) to do that ?
One way I thought is to Recursively query for time using date command and run it through a for loop(checks for hours) within a for loop(checks for minutes) until time reaches the preset time.
Is it the correct approach? are there any other Smart ways of writing it?
Well, I think the best way would be to create a cron job.
With cron you don’t have to worry about timing etc, you just create a task. Take a look at its wiki and manual, it’s really simple.
You can find an example how to set things up here. It’s based on Mint Linux, but should work on any distribution.