Giter Site home page Giter Site logo

Comments (17)

chutzimir avatar chutzimir commented on June 26, 2024 1

If you use a command different than apt-mirror does that work? This does not seem to be an apt-mirror problem. What is the modification time of /var/spool/apt-mirror/var/cron.log? Did you restart the cron daemon?

from apt-mirror.

ombonbon avatar ombonbon commented on June 26, 2024

Hallo @siutung
According to man page here, you must include the username for cron jobs inside /etc/cron.d folder.
In your case, it looks like the username is not separated by a space.
Should be:
0 4 * * * apt-mirror /usr/bin/apt-mirror>/var/spool/apt-mirror/var/cron.log

from apt-mirror.

siutung avatar siutung commented on June 26, 2024

@ombonbon
Thanks for the reply.

The issue with the missing space character may have been due to my mistake in getting it off.
But there is actually a space in that place.

My /etc/cron.d/apt-mirror has the following contents:
0 4 * * * apt-mirror /usr/bin/apt-mirror > /var/spool/apt-mirror/var/cron.log

The permissions (default) for the /etc/cron.d/apt-mirror file are:
-rw-r--r-- 1 root root 129 Nov 10 14:39 apt-mirror

Also, my cron service is running: active (running)

I don't know what the reason is, apt-mirror doesn't update the source at that point in time.

from apt-mirror.

chutzimir avatar chutzimir commented on June 26, 2024

0 4 * * * * apt-mirror /usr/bin/apt-mirror > /var/spool/apt-mirror/var/cron.log

This looks like it has one * too many.

man 5 crontab

Each line has five time and date fields, followed by a user name if this is the system crontab file, followed by a command.

You have six fields followed by a username.

from apt-mirror.

siutung avatar siutung commented on June 26, 2024

Yes,there has one * to many.
there apt-mirror content are:
0 4 * * * apt-mirror /usr/bin/apt-mirror > /var/spool/apt-mirror/var/cron.log

But 2 days have passed and the /var/spool/apt-mirror/var/cron.log file is empty, and I can update (download) a lot of updates by manually running sudo apt-mirror.
I suspect apt-mirror is not automatically running at 4am every morning.
So I'm trying to find out where exactly the problem is occurring.

from apt-mirror.

ombonbon avatar ombonbon commented on June 26, 2024

hallo @siutung
if you can run manually "$sudo apt-mirror", then it is interesting as which user is the cron job running.
did you simply "$crontab -e", or "$sudo crontab -e"?
if you did the first, then your crontab should use:
0 4 * * * sudo apt-mirror > /var/spool/apt-mirror/var/cron.log
if you did the second one, then your crontab should use:
0 4 * * * apt-mirror > /var/spool/apt-mirror/var/cron.log
the first will only work if you have defined the crontab user to use sudo without being asked for root password (like the default in raspberry pi).

from apt-mirror.

siutung avatar siutung commented on June 26, 2024

@chutzimir Thanks for your help!
I check the update from upstream site do:
$ sudo apt-mirror
It can be update with manual.

I check the /var/spool/apt-mirror/var/cron.log file,it was update time is 04:00,but it it empty:
0 4 * * * apt-mirror /usr/bin/apt-mirror > /var/spool/apt-mirror/var/cron.log

$ ls -l /var/spool/apt-mirror/var/cron.log
-rw-rw-r-- 1 apt-mirror apt-mirror 0 Nov 14 04:00 /var/spool/apt-mirror/var/cron.log

from apt-mirror.

siutung avatar siutung commented on June 26, 2024

@ombonbon Thanks for your help,also.
Whether I use $ crontab -e or $ sudo crontab -e,the crontab file were default content with "#"
But the /etc/cron.d/apt-mirror file is:
0 4 * * * apt-mirror /usr/bin/apt-mirror > /var/spool/apt-mirror/var/cron.log
it means the cron was running use apt-mirror user.

Default the line with "#",so I delete the "#" let it take effect.

The update time of the cron.log file proves that the apt-mirror scheduled task has taken effect.

But actually:

1, Updates are not being downloaded, I come in every morning and run apt-mirror manually and there are a lot of updates being downloaded from the upstream server.

2, Why the /var/spool/apt-mirror/var/cron.log file is empty?

from apt-mirror.

chutzimir avatar chutzimir commented on June 26, 2024

Put a & In front of the redirect so you can also see the stderr in the log.

Like this: &>/var/spool/apt-mirror/var/cron.log.

from apt-mirror.

siutung avatar siutung commented on June 26, 2024

@chutzimir
my /etc/cron.d/apt-mirror content are:
0 4 * * * apt-mirror /usr/bin/apt-mirror &> /var/spool/apt-mirror/var/cron.log

I will come back and saw the cron.log.:)

thank you so much!

from apt-mirror.

siutung avatar siutung commented on June 26, 2024

@ombonbon @chutzimir
I checked the /var/spool/apt-mirror/var/cron.log file,this morning:
-rw-rw-r-- 1 apt-mirror apt-mirror 0 Nov 15 04:00 /var/spool/apt-mirror/var/cron.log

the apt-mirror file content is:
0 4 * * * apt-mirror /usr/bin/apt-mirror &> /var/spool/apt-mirror/var/cron.log

I see that the file has been updated, but the file is still empty.:(

from apt-mirror.

chutzimir avatar chutzimir commented on June 26, 2024

A few more ideas to check what is wrong with it.

  1. Produce more debugging output. There is a chance the command is not starting at all for whatever reason.

Try this

0 4 * * * apt-mirror /bin/bash -xc /usr/bin/apt-mirror &> /var/spool/apt-mirror/var/cron.log

And instead of waiting for next day, feel free to change the time so it starts next minute. You can also watch the logs with sudo journalctl -f to see if there is anything logged in there.

from apt-mirror.

siutung avatar siutung commented on June 26, 2024

@chutzimir
The time the cron.log file was generated has been updated, though it is still an empty file.

$ journalctl -f
-- Logs begin at Fri 2023-09-15 15:18:13 CST. --
Nov 16 11:36:43 localhost sudo[70466]: user : TTY=pts/1 ; PWD=/etc/cron.d ; USER=root ; COMMAND=/usr/bin/systemctl restart cron
Nov 16 11:36:43 localhost sudo[70466]: pam_unix(sudo:session): session opened for user root by user(uid=0)
Nov 16 11:36:43 localhost systemd[1]: Stopping Regular background program processing daemon...
Nov 16 11:36:43 localhost systemd[1]: cron.service: Succeeded.
Nov 16 11:36:43 localhost systemd[1]: Stopped Regular background program processing daemon.
Nov 16 11:36:43 localhost systemd[1]: Started Regular background program processing daemon.
Nov 16 11:36:43 localhost sudo[70466]: pam_unix(sudo:session): session closed for user root
Nov 16 11:36:43 localhost cron[70469]: (CRON) INFO (pidfile fd = 3)
Nov 16 11:36:43 localhost cron[70469]: (CRON) INFO (Skipping @reboot jobs -- not system startup)
Nov 16 11:40:01 localhost CRON[70519]: (apt-mirror) CMD (/bin/bash -xc /usr/bin/apt-mirror &> /var/spool/apt-mirror/var/cron.log)

When I manually execute the sudo apt-mirror command, the system still pulls several hundred megabytes from the upstream apt server.The cron.log file remains empty.

from apt-mirror.

chutzimir avatar chutzimir commented on June 26, 2024

Next would be to check if cron logged any errors. Normally those are sent by mail, but for apt-mirror these are likely pooled on the local:

sudo cat /var/spool/mail/apt-mirror

from apt-mirror.

apavely avatar apavely commented on June 26, 2024

I have seen a case of this being a permissions issue, where apt-mirror was run as root (with sudo), which then created files in /var/spool/apt-mirror/ owned by root, and consequently, these files could not be overwritten by the apt-mirror user defined in the cronjob.

You should be able to see the problem if you run it directly as the apt-mirror user, looking something like this:

$ sudo -u apt-mirror apt-mirror
flock() on closed filehandle LOCK_FILE at /usr/bin/apt-mirror line 214.
apt-mirror is already running, exiting at /usr/bin/apt-mirror line 217.

This can be fixed by:

sudo chown -R apt-mirror /var/spool/apt-mirror/

(which should also be done to your configured $mirror_path).

from apt-mirror.

siutung avatar siutung commented on June 26, 2024

@apavely @chutzimir @ombonbon
Thanks for your help.
I have taken care of this issue last month.
I changed the contents of /etc/cron.d/apt-mirror to:

0 */6 * * * * root /usr/bin/apt-mirror > /var/spool/apt-mirror/var/cron.log 2>&1 &
30 */6 * * * * root /data/apt-mirror/var/clean.sh 2>&1 &

Let apt-mirror perform the update as the root user.
Now it's working fine.
But I'm not sure if it's accurate to do so (permissions related)._

from apt-mirror.

kenyon avatar kenyon commented on June 26, 2024

@siutung can you close this, since you have resolved it?

Also, it's not necessary to redirect the output of cron jobs to a log file. If you have a mail transfer agent set up, cron will mail the output. See cron documentation for details. Alternatively, I would recommend converting your cron job to a systemd timer and service, which by default logs standard output to the systemd journal, which is also usually replicated in syslog.

from apt-mirror.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.