Checking if package is older than 24 hours with bash

install r linux
how to check if cygwin is installed on windows
cran
r package archive
r packages
download r 3.5.1 for linux
install.packages r
r-crain

I would like to check if my last file is older than 24 hours or not. (project in django) I have many zip packages in directory so I have to 'filter' the last one with this part of code: ls -1 | sort -n | tail -n1.

My code in .sh file:

#!/bin/bash

file="$HOME/path_directory ls -1 | sort -n | tail -n1"
current=`date +%s`;
last_modified=`stat -c "%Y" $file`;


if [ $(($current-$last_modified)) -gt 86400 ]; then
     echo "File is older that 24 hours" | mailx noreply@address -s "Older than 24 hours" me@mailmail.com
else
     echo "File is up to date.";
fi;

Here is an error, that I got:

stat: invalid option -- '1'
Try 'stat --help' for more information.
/path_directory/imported_file.sh: line 9: 1538734802-: syntax error: operand expected (error token is "-")

If somebody made something similar, please some hint.

I'd advise you to try this:

if test "`find file -mtime +1`"

but if you insist you can fix it by changing it to this:

#!/bin/bash
file="$HOME/path_directory ls -1 | sort -n | tail -n1"
current=$(date +%s);
last_modified=$(stat -c "%Y" $file);

if [ $((current - last_modified)) -gt 86400 ]; then
     echo "File is older that 24 hours" | mailx noreply@address -s "Older than 24 hours" me@mailmail.com
else
     echo "File is up to date.";
fi;

If the specified time has already passed, the operation is scheduled for the next occurrence of that Day specification To schedule an at job more than 24 hours in advance, you must add a day If it's not, check for its presence using ps. Find and Delete Files Older Than X Days In Linux. First, let us find out the files older than X days, for example 30 days. To do, so, just run: $ find . -mtime +30 -print. The above command will find and display the older files which are older than 30 day in the current working directorys. Here, dot (.) – Represents the current directory.

You can obtain the list of files in the directory that have been modified earlier than 1440 minutes (86400 seconds), you can use find for this:

find -maxdepth 1 -mmin +1440

It will thus select all files in this directory (no subdirectories), with a change time in minutes older than 1440.

The + in +1440 is important, since otherwise you will obtain files that are exactly 1440 minutes unmodified.

You can also use -mtime to specify the number in days:

find -maxdepth 1 -mtime +1

If you want all files (in this directory and subdirectories), you can remove the -maxdepth 1.

You can add -type f if you only want to include files, etc. For more flags, and (filtering) options, please read the manpage of find.

If the specified time has already passed, the operation is scheduled for the next Day specification To schedule an at job more than 24 hours in advance, you must add a day its own prompt, at>, which you can treat much like your normal bash or other command shell prompt. If it's not, check for its presence using ps. #! /bin/bash # This checks that the specified file is less than 28 hours old. # returns 0 if younger than 28 hours. # returns 1 if older than 28 hours. # funtion arguments -> filename to comapre against curr time: function comparedate() {if [ !-f $1]; then: echo " file $1 does not exist " exit 1: fi: MAXAGE= $(bc <<< ' 28*60*60 ') # seconds in

The file variable are not well formed I belive that you want something like:

file=`find $HOME/path_directory | sort -n | tail -n1`

or

file=$( find $HOME/path_directory | sort -n | tail -n1)

If you like the moderm way

When Models Break Down Over short periods of time, populations can be modeled 10101 is , not which to bash is smaller than exponential a molecule of chocolate. growth or decay as a model. Rather, the lesson is to always do a sanity check when working with models. How many bacteria will there be in 24 hours? Re: Bash Script checking time, You must have changed something. Anyway, rather than sleeping and re-checking all the time, better just check *once* and then use the "at(1)" command

It doesn't seem so long ago we were licking our wounds after the seasons Every second year the NAFCSC have the big bash in the Riviera in Las Vegas, while the playing out in my head) the flight was eventually cancelled for 24 hours. for me whenever and wherever I go there were more problems ahead at check in  Note that both find -mtime +1 and zsh's *(m+1) find files that are at least 48 hours old, not files older than today. The plus sign means “strictly more than” and the number of days is rounded down. To find files that are at least 24 hours old, use -mtime +0 or (m+0).

Golfing oldster Emil Kijek was ecstatic when his ball dropped in the cup for the other members of the foursome were more excited about the "ace" than Kijek. Newspaper goof has boozers flocking Check out this correction that red-faced A car bash will be part of the event. Free literature: send or call 24 hours a day.

Also if we could make them cheaper than we could buy our tile. a number of pallet boards on which the tiles are placed to dry 24 hours before being moved. Write today for free samples or test and comparison and our unparalleled selling plan. We offersome very fine new varieties as well as the best of the older kinds​.

Comments
  • Why not with find?
  • Using back-ticks for command substitutions is deprecated in favor of $(command). The later form is more readable.
  • Using back-ticks for command substitutions is deprecated in favor of $(command). The later form is more readable.
  • @ben Thanks a lot :)
  • cmin and ctime represent the last inode change-time (permissions, name, etc.). The OP wants the last modification timestamps --- mmin and mtime.
  • @JRFerguson: arrgh... Yes, ctime handles the meta-data. But mtime handles the content :)
  • Using back-ticks for command substitutions is deprecated in favor of $(command). The later form is more readable.