Skip to main content
Reflect the OP's requirements rather than just copying their example
Source Link
Chris Davies
  • 128.4k
  • 16
  • 179
  • 324

logrotate can be run as an ordinary user, without administrative privileges, to rotate logs for that user.

# Create a local per-user configuration file
cat >.logrotate.conf <<'X'
/home/mike/tmp/qqq.log {
    notifempty
  size 1M
  dailymissingok
  create 0664 mikesize mike1M
    rotate 3
}
X

# Run logrotate with that configuration file
/usr/sbin/logrotate -v -s .logrotate.state .logrotate.conf

You'll find that the first time it runs, nothing happens. This is becauseI've removed your logrotatedaily has no initial state so it needs to set it up. In your casecriterion because you wanted purely a size-based check, regardless of the number of timesand this would have limited any possible action to just once a day (the first time each day that logrotate is re-runrun, no further changes will be made until specified criteria have been met (i.eas it happens). I've replaced notifemptycreate, with size 1Mmissingok, so that it's up to your actual dailyrclone). You can cheat by editing job to create the output file rather than .logrotate.state file if you are comfortable doing so, rolling its time value back at least one day.

Then put the logrotate command into your user's crontab file:

# Capture any existing crontab entries
crontab -l >.crontab

# Append ours to the list
echo '0 * * * * /usr/sbin/logrotate -s .logrotate.state .logrotate.conf >>.crontab.log 2>&1' >>.crontab

# Reload crontab
crontab .crontab

Using this example, output from the command will be written to .crontab.log, and you'll probably want a logrotate entry to cycle or reset it monthly.

logrotate can be run as an ordinary user, without administrative privileges, to rotate logs for that user.

# Create a local per-user configuration file
cat >.logrotate.conf <<'X'
/home/mike/tmp/qqq.log {
  notifempty
  size 1M
  daily
  create 0664 mike mike
  rotate 3
}
X

# Run logrotate with that configuration file
/usr/sbin/logrotate -s .logrotate.state .logrotate.conf

You'll find that the first time it runs, nothing happens. This is because logrotate has no initial state so it needs to set it up. In your case, regardless of the number of times logrotate is re-run, no further changes will be made until specified criteria have been met (i.e. notifempty, size 1M, daily). You can cheat by editing the .logrotate.state file if you are comfortable doing so, rolling its time value back at least one day.

Then put the logrotate command into your user's crontab file:

# Capture any existing crontab entries
crontab -l >.crontab

# Append ours to the list
echo '0 * * * * /usr/sbin/logrotate -s .logrotate.state .logrotate.conf >>.crontab.log 2>&1' >>.crontab

# Reload crontab
crontab .crontab

Using this example, output from the command will be written to .crontab.log, and you'll probably want a logrotate entry to cycle or reset it monthly.

logrotate can be run as an ordinary user, without administrative privileges, to rotate logs for that user.

# Create a local per-user configuration file
cat >.logrotate.conf <<'X'
/home/mike/tmp/qqq.log {
    notifempty
    missingok
    size 1M
    rotate 3
}
X

# Run logrotate with that configuration file
/usr/sbin/logrotate -v -s .logrotate.state .logrotate.conf

I've removed your daily criterion because you wanted purely a size-based check, and this would have limited any possible action to just once a day (the first time each day that logrotate is run, as it happens). I've replaced create with missingok so that it's up to your actual rclone job to create the output file rather than logrotate.

Then put the logrotate command into your user's crontab file:

# Capture any existing crontab entries
crontab -l >.crontab

# Append ours to the list
echo '0 * * * * /usr/sbin/logrotate -s .logrotate.state .logrotate.conf >>.crontab.log 2>&1' >>.crontab

# Reload crontab
crontab .crontab

Using this example, output from the command will be written to .crontab.log, and you'll probably want a logrotate entry to cycle or reset it monthly.

Removed an extra "no"
Source Link
Jeff Schaller
  • 68.8k
  • 35
  • 122
  • 267

logrotate can be run as an ordinary user, without administrative privileges, to rotate logs for that user.

# Create a local per-user configuration file
cat >.logrotate.conf <<'X'
/home/mike/tmp/qqq.log {
  notifempty
  size 1M
  daily
  create 0664 mike mike
  rotate 3
}
X

# Run logrotate with that configuration file
/usr/sbin/logrotate -s .logrotate.state .logrotate.conf

You'll find that the first time it runs, nothing happens. This is because logrotate has no initial state so it needs to set it up. In your case, no regardless of the number of times logrotate is re-run, no further changes will be made until specified criteria have been met (i.e. notifempty, size 1M, daily). You can cheat by editing the .logrotate.state file if you are comfortable doing so, rolling its time value back at least one day.

Then put the logrotate command into your user's crontab file:

# Capture any existing crontab entries
crontab -l >.crontab

# Append ours to the list
echo '0 * * * * /usr/sbin/logrotate -s .logrotate.state .logrotate.conf >>.crontab.log 2>&1' >>.crontab

# Reload crontab
crontab .crontab

Using this example, output from the command will be written to .crontab.log, and you'll probably want a logrotate entry to cycle or reset it monthly.

logrotate can be run as an ordinary user, without administrative privileges, to rotate logs for that user.

# Create a local per-user configuration file
cat >.logrotate.conf <<'X'
/home/mike/tmp/qqq.log {
  notifempty
  size 1M
  daily
  create 0664 mike mike
  rotate 3
}
X

# Run logrotate with that configuration file
/usr/sbin/logrotate -s .logrotate.state .logrotate.conf

You'll find that the first time it runs, nothing happens. This is because logrotate has no initial state so it needs to set it up. In your case, no regardless of the number of times logrotate is re-run, no further changes will be made until specified criteria have been met (i.e. notifempty, size 1M, daily). You can cheat by editing the .logrotate.state file if you are comfortable doing so, rolling its time value back at least one day.

Then put the logrotate command into your user's crontab file:

# Capture any existing crontab entries
crontab -l >.crontab

# Append ours to the list
echo '0 * * * * /usr/sbin/logrotate -s .logrotate.state .logrotate.conf >>.crontab.log 2>&1' >>.crontab

# Reload crontab
crontab .crontab

Using this example, output from the command will be written to .crontab.log, and you'll probably want a logrotate entry to cycle or reset it monthly.

logrotate can be run as an ordinary user, without administrative privileges, to rotate logs for that user.

# Create a local per-user configuration file
cat >.logrotate.conf <<'X'
/home/mike/tmp/qqq.log {
  notifempty
  size 1M
  daily
  create 0664 mike mike
  rotate 3
}
X

# Run logrotate with that configuration file
/usr/sbin/logrotate -s .logrotate.state .logrotate.conf

You'll find that the first time it runs, nothing happens. This is because logrotate has no initial state so it needs to set it up. In your case, regardless of the number of times logrotate is re-run, no further changes will be made until specified criteria have been met (i.e. notifempty, size 1M, daily). You can cheat by editing the .logrotate.state file if you are comfortable doing so, rolling its time value back at least one day.

Then put the logrotate command into your user's crontab file:

# Capture any existing crontab entries
crontab -l >.crontab

# Append ours to the list
echo '0 * * * * /usr/sbin/logrotate -s .logrotate.state .logrotate.conf >>.crontab.log 2>&1' >>.crontab

# Reload crontab
crontab .crontab

Using this example, output from the command will be written to .crontab.log, and you'll probably want a logrotate entry to cycle or reset it monthly.

added 20 characters in body
Source Link
Chris Davies
  • 128.4k
  • 16
  • 179
  • 324

logrotate can be run as an ordinary user, without administrative privileges, to rotate logs for that user.

# Create a local per-user configuration file
cat >.logrotate.conf <<'X'
/home/mike/tmp/qqq.log {
  notifempty
  size 1M
  daily
  create 0664 mike mike
  rotate 3
}
X

# Run logrotate with that configuration file
/usr/sbin/logrotate -s .logrotate.state .logrotate.conf

You'll find that the first time it runs, nothing happens. This is because logrotate has no initial state so it needs to set it up. In your case, no regardless of the number of times logrotate is re-run, no further changes will be made until specified criteria have been met (i.e. notifempty, size 1M, daily). You can cheat by editing the .logrotate.state file if you are comfortable doing so, rolling its time value back at least one day.

Then put the logrotate command into your user's crontab file:

# Capture any existing crontab entries
crontab -l >.crontab

# Append ours to the list
echo '0 * * * * /usr/sbin/logrotate -s .logrotate.state .logrotate.conf >>.crontab.log 2>&1' >>.crontab

# Reload crontab
crontab .crontab

Using this example, output from the command will be written to .crontab.log, and you'll probably want a logrotate entry to cycle or reset it monthly.

logrotate can be run as an ordinary user, without administrative privileges, to rotate logs for that user.

# Create a local per-user configuration file
cat >.logrotate.conf <<'X'
/home/mike/tmp/qqq.log {
  notifempty
  size 1M
  daily
  create 0664 mike mike
  rotate 3
}
X

# Run logrotate with that configuration file
logrotate -s .logrotate.state .logrotate.conf

You'll find that the first time it runs, nothing happens. This is because logrotate has no initial state so it needs to set it up. In your case, no regardless of the number of times logrotate is re-run, no further changes will be made until specified criteria have been met (i.e. notifempty, size 1M, daily). You can cheat by editing the .logrotate.state file if you are comfortable doing so, rolling its time value back at least one day.

Then put the logrotate command into your user's crontab file:

# Capture any existing crontab entries
crontab -l >.crontab

# Append ours to the list
echo '0 * * * * logrotate -s .logrotate.state .logrotate.conf >>.crontab.log 2>&1' >>.crontab

# Reload crontab
crontab .crontab

Using this example, output from the command will be written to .crontab.log, and you'll probably want a logrotate entry to cycle or reset it monthly.

logrotate can be run as an ordinary user, without administrative privileges, to rotate logs for that user.

# Create a local per-user configuration file
cat >.logrotate.conf <<'X'
/home/mike/tmp/qqq.log {
  notifempty
  size 1M
  daily
  create 0664 mike mike
  rotate 3
}
X

# Run logrotate with that configuration file
/usr/sbin/logrotate -s .logrotate.state .logrotate.conf

You'll find that the first time it runs, nothing happens. This is because logrotate has no initial state so it needs to set it up. In your case, no regardless of the number of times logrotate is re-run, no further changes will be made until specified criteria have been met (i.e. notifempty, size 1M, daily). You can cheat by editing the .logrotate.state file if you are comfortable doing so, rolling its time value back at least one day.

Then put the logrotate command into your user's crontab file:

# Capture any existing crontab entries
crontab -l >.crontab

# Append ours to the list
echo '0 * * * * /usr/sbin/logrotate -s .logrotate.state .logrotate.conf >>.crontab.log 2>&1' >>.crontab

# Reload crontab
crontab .crontab

Using this example, output from the command will be written to .crontab.log, and you'll probably want a logrotate entry to cycle or reset it monthly.

Source Link
Chris Davies
  • 128.4k
  • 16
  • 179
  • 324
Loading