# phpman > man > savelog(8)

[SAVELOG(8)](https://www.chedong.com/phpMan.php/man/SAVELOG/8/markdown)                             System Manager's Manual                            [SAVELOG(8)](https://www.chedong.com/phpMan.php/man/SAVELOG/8/markdown)



## NAME
       savelog - save a log file

## SYNOPSIS
       **savelog**  [-m  mode]  [-u user] [-g group] [-t] [-p] [-c cycle] [-l] [-j] [-J] [-1 .. -9] [-C]
       [-d] [-l] [-r rolldir] [-n] [-q] [-D dateformat] file ...

## DESCRIPTION
       The **savelog** command saves and optionally compresses old copies of files.  Older  versions  of
       _file_ are named:

              _file_._<number><compress_suffix>_

       where _<number>_ is the version number, 0 being the newest.  Version numbers > 0 are compressed
       unless **-l** prevents it.  Version number 0 is not compressed because a process might still have
       _file_ opened for I/O.  Only _cycle_ versions of the file are kept.

       If the file does not exist and **-t** was given, it will be created.

       For  files  that  do exist and have lengths greater than zero, the following actions are per‐
       formed:


       1)     Version numbered files are cycled.  Version _file_**.2** is moved to version _file_**.3**, version
              _file_**.1** is moved to version _file_**.2**, and so on.  Finally version _file_**.0** is moved to ver‐
              sion _file_**.1**, and version _file_ is deleted.   Both  compressed  names  and  uncompressed
              names are cycled, regardless of **-l**.  Missing version files are ignored.

       2)     The  new  _file_**.1** is compressed unless the **-l** flag was given.  It is changed subject to
              the **-m**, **-u**, and **-g** flags.

       3)     The main _file_ is moved to _file_**.0**.

       4)     If the **-m**, **-u**, **-g**,  **-t**, or **-p** flags are given, then an empty _file_ is  created  subject
              to the given flags.  With the **-p** flag, the file is created with the same owner, group,
              and permissions as before.

       5)     The new _file_**.0** is changed subject to the **-m**, **-u**, and **-g** flags.

## OPTIONS
### -m mode
              chmod the log files to mode, implies **-t**

### -u user
              chown log files to user, implies **-t**

### -g group
              chgrp log files to group, implies **-t**

### -c cycle
              Save cycle versions of the logfile (default: 7).  The _cycle_ count must be at least 2.

### -t

### -l

### -p

### -j

### -J

              For xz no strength option is set, and xz decides on the default  based  on  the  total
              amount  of  physical  RAM.  Note that xz can use a very large amount of memory for the
              higher compression levels.

### -1 .. -9
              compression strength or memory usage (default: 9, except for xz)

### -C

### -d

### -D dateformat
              override date format, in the syntax understood by the [**date**(1)](https://www.chedong.com/phpMan.php/man/date/1/markdown) command

### -r

### -n

### -q

## BUGS
       If a process is still writing to _file_**.0**, and savelog moves it to _file_**.1**  and  compresses  it,
       data could be lost.

## SEE ALSO
       [**logrotate**(8)](https://www.chedong.com/phpMan.php/man/logrotate/8/markdown)



Debian                                       30 Dec 2017                                  [SAVELOG(8)](https://www.chedong.com/phpMan.php/man/SAVELOG/8/markdown)
