question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Doesn't work when used within proces runner such as PM2 or CRONtab?

See original GitHub issue

I’ve added script to my crontab somewhat like this:

@reboot /path/to/script
* * * * * /path/to/script

code runs, however there is no notification.

return notifier.notify({
  title: 'foo',
  message: randomMessage(),
})

Same issue with PM2. So it appears that when it’s being ran by some different process, not from user’s shell, then it fails to send notification to desktop.

Same issue when using with gnome-session-properties. Linked SO question: https://stackoverflow.com/questions/49221716/when-using-notify-send-inside-some-process-runner-such-as-cron-or-pm2-notificat

Versions: Ubuntu 16.04 Gnome3 (gubuntu distro). notify-send 0.7.6 “node-notifier”: “^5.2.1”,

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
SPDUKcommented, Apr 23, 2019

I’m trying to send notifications from cron, and the notifications don’t display under ubuntu 19.04. It does work under task scheduler on windows 10, though (using the exact same scripts).

Trying to run notify-send in general from cron does not work properly, but I found a this on SO which makes it work correctly from cron * * * * * XDG_RUNTIME_DIR=/run/user/$(id -u) notify-send Hey "this is dog!

So in my .sh script I’ve added export XDG_RUNTIME_DIR=/run/user/$(id -u) to the top of it, and that has made it work from cron for linux.

0reactions
mikaelbrcommented, Oct 28, 2020

Related to #333

Read more comments on GitHub >

github_iconTop Results From Across the Web

When using notify-send inside some process runner such as ...
It works when script is ran from user's CLI, but if I run this code via CRON ( crontab -e ) or PM2...
Read more >
PM2: Run cron-job from single process in cluster mode
So this works fine if we run the code in fork mode (single process). But the problem occurs when we run the project...
Read more >
A Complete Guide to Node.js Process Management with PM2
PM2 is a Node.js process manager that comes with a built-in load balancer. ... To list your running applications, use the pm2 list...
Read more >
How to Deploy, Manage and Scale Node.js Apps with PM2
PM2 is an open-source process manager for Node.js applications that allows you to monitor and manage your application's lifecycle in ...
Read more >
Quick Start - PM2
Advanced process manager for production Node.js applications. Load balancer, logs facility, startup script, micro service management, at a glance.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found